grav controller json

Run Settings
LanguageLua
Language Version
Run Command
{"AnimationHandler":"local AnimationHandler = {}\r\nAnimationHandler.__index = AnimationHandler\r\n\r\nfunction AnimationHandler.new(humanoid, animate)\r\n\tlocal self = setmetatable({}, AnimationHandler)\r\n\t\r\n\tself._AnimFuncs = require(\"Animate.Controller\")\r\n\tself.Humanoid = humanoid\r\n\t\r\n\treturn self\r\nend\r\n\r\nfunction AnimationHandler:EnableDefault(bool)\r\n\tif (bool) then\r\n\t\tself._AnimFuncs.onHook()\r\n\telse\r\n\t\tself._AnimFuncs.onUnhook()\r\n\tend\r\nend\r\n\r\nfunction AnimationHandler:Run(name, ...)\r\n\tself._AnimFuncs[name](...)\r\nend\r\n\r\nreturn AnimationHandler","CameraModifier":"local UIS = game:GetService(\"UserInputService\")\r\nlocal UserGameSettings = UserSettings():GetService(\"UserGameSettings\")\r\n\r\nlocal CameraModifier = {}\r\nCameraModifier.__index = CameraModifier\r\n\r\nlocal FFlagUserCameraToggle do\r\n\tlocal success, result = pcall(function()\r\n\t\treturn UserSettings():IsUserFeatureEnabled(\"UserCameraToggle\")\r\n\tend)\r\n\tFFlagUserCameraToggle = success and result\r\nend\r\n\r\nfunction CameraModifier.new(player)\r\n\tlocal self = setmetatable({}, CameraModifier)\r\n\t\r\n\tlocal playerModule = player.PlayerScripts:WaitForChild(\"PlayerModule\")\r\n\tlocal cameraModule = playerModule:WaitForChild(\"CameraModule\")\r\n\tlocal basecam = require(cameraModule:WaitForChild(\"BaseCamera\"))\r\n\tlocal cameraInput = require(cameraModule:WaitForChild(\"CameraInput\"))\r\n\tlocal cameraUI = require(cameraModule:WaitForChild(\"CameraUI\"))\r\n\tlocal cameraToggleStateController = require(cameraModule:WaitForChild(\"CameraToggleStateController\"))\r\n\t\r\n\tself.IsCamLocked = false\r\n\tself.BaseClass = basecam\r\n\tself.DefaultMouseBehavior = basecam.UpdateMouseBehavior\r\n\t\r\n\tfunction basecam.UpdateMouseBehavior(this)\r\n\t\tif FFlagUserCameraToggle and this.isCameraToggle then\r\n\t\t\tcameraUI.setCameraModeToastEnabled(true)\r\n\t\t\tcameraInput.enableCameraToggleInput()\r\n\t\t\tcameraToggleStateController(this.inFirstPerson)\r\n\t\telse\r\n\t\t\tif FFlagUserCameraToggle then\r\n\t\t\t\tcameraUI.setCameraModeToastEnabled(false)\r\n\t\t\t\tcameraInput.disableCameraToggleInput()\r\n\t\t\tend\r\n\t\t\t-- first time transition to first person mode or mouse-locked third person\r\n\t\t\tif this.inFirstPerson or this.inMouseLockedMode then\r\n\t\t\t\tUserGameSettings.RotationType = Enum.RotationType.CameraRelative\r\n\t\t\t\tUIS.MouseBehavior = Enum.MouseBehavior.LockCenter\r\n\t\t\t\t\r\n\t\t\t\tself.IsCamLocked = true\r\n\t\t\telse\r\n\t\t\t\tUserGameSettings.RotationType = Enum.RotationType.MovementRelative\r\n\t\t\t\tif this.isRightMouseDown or this.isMiddleMouseDown then\r\n\t\t\t\t\tUIS.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition\r\n\t\t\t\telse\r\n\t\t\t\t\tUIS.MouseBehavior = Enum.MouseBehavior.Default\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\t\t\t\tself.IsCamLocked = false\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\n\treturn self\r\nend\r\n\r\n-- Public methods\r\n\r\nfunction CameraModifier:Destroy()\r\n\tself.BaseClass.UpdateMouseBehavior = self.DefaultMouseBehavior\r\nend\r\n\r\n--\r\n\r\nreturn CameraModifier","Animate.R6":"return function(script)\r\n\t\r\n\tlocal Figure = script.Parent\r\n\tlocal Torso = Figure:WaitForChild(\"Torso\")\r\n\tlocal RightShoulder = Torso:WaitForChild(\"Right Shoulder\")\r\n\tlocal LeftShoulder = Torso:WaitForChild(\"Left Shoulder\")\r\n\tlocal RightHip = Torso:WaitForChild(\"Right Hip\")\r\n\tlocal LeftHip = Torso:WaitForChild(\"Left Hip\")\r\n\tlocal Neck = Torso:WaitForChild(\"Neck\")\r\n\tlocal Humanoid = Figure:WaitForChild(\"Humanoid\")\r\n\tlocal pose = \"Standing\"\r\n\t\r\n\tlocal currentAnim = \"\"\r\n\tlocal currentAnimInstance = nil\r\n\tlocal currentAnimTrack = nil\r\n\tlocal currentAnimKeyframeHandler = nil\r\n\tlocal currentAnimSpeed = 1.0\r\n\tlocal animTable = {}\r\n\tlocal animNames = { \r\n\t\tidle = \t{\t\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=180435571\", weight = 9 },\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=180435792\", weight = 1 }\r\n\t\t\t\t},\r\n\t\twalk = \t{ \t\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=180426354\", weight = 10 } \r\n\t\t\t\t}, \r\n\t\trun = \t{\r\n\t\t\t\t\t{ id = \"run.xml\", weight = 10 } \r\n\t\t\t\t}, \r\n\t\tjump = \t{\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=125750702\", weight = 10 } \r\n\t\t\t\t}, \r\n\t\tfall = \t{\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=180436148\", weight = 10 } \r\n\t\t\t\t}, \r\n\t\tclimb = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=180436334\", weight = 10 } \r\n\t\t\t\t}, \r\n\t\tsit = \t{\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=178130996\", weight = 10 } \r\n\t\t\t\t},\t\r\n\t\ttoolnone = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182393478\", weight = 10 } \r\n\t\t\t\t},\r\n\t\ttoolslash = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=129967390\", weight = 10 } \r\n\t--\t\t\t\t{ id = \"slash.xml\", weight = 10 } \r\n\t\t\t\t},\r\n\t\ttoollunge = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=129967478\", weight = 10 } \r\n\t\t\t\t},\r\n\t\twave = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=128777973\", weight = 10 } \r\n\t\t\t\t},\r\n\t\tpoint = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=128853357\", weight = 10 } \r\n\t\t\t\t},\r\n\t\tdance1 = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182435998\", weight = 10 }, \r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182491037\", weight = 10 }, \r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182491065\", weight = 10 } \r\n\t\t\t\t},\r\n\t\tdance2 = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182436842\", weight = 10 }, \r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182491248\", weight = 10 }, \r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182491277\", weight = 10 } \r\n\t\t\t\t},\r\n\t\tdance3 = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182436935\", weight = 10 }, \r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182491368\", weight = 10 }, \r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=182491423\", weight = 10 } \r\n\t\t\t\t},\r\n\t\tlaugh = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=129423131\", weight = 10 } \r\n\t\t\t\t},\r\n\t\tcheer = {\r\n\t\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=129423030\", weight = 10 } \r\n\t\t\t\t},\r\n\t}\r\n\tlocal dances = {\"dance1\", \"dance2\", \"dance3\"}\r\n\t\r\n\t-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote\r\n\tlocal emoteNames = { wave = false, point = false, dance1 = true, dance2 = true, dance3 = true, laugh = false, cheer = false}\r\n\t\r\n\tfunction configureAnimationSet(name, fileList)\r\n\t\tif (animTable[name] ~= nil) then\r\n\t\t\tfor _, connection in pairs(animTable[name].connections) do\r\n\t\t\t\tconnection:disconnect()\r\n\t\t\tend\r\n\t\tend\r\n\t\tanimTable[name] = {}\r\n\t\tanimTable[name].count = 0\r\n\t\tanimTable[name].totalWeight = 0\t\r\n\t\tanimTable[name].connections = {}\r\n\t\r\n\t\t-- check for config values\r\n\t\tlocal config = script:FindFirstChild(name)\r\n\t\tif (config ~= nil) then\r\n\t--\t\tprint(\"Loading anims \" .. name)\r\n\t\t\ttable.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))\r\n\t\t\ttable.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))\r\n\t\t\tlocal idx = 1\r\n\t\t\tfor _, childPart in pairs(config:GetChildren()) do\r\n\t\t\t\tif (childPart:IsA(\"Animation\")) then\r\n\t\t\t\t\ttable.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))\r\n\t\t\t\t\tanimTable[name][idx] = {}\r\n\t\t\t\t\tanimTable[name][idx].anim = childPart\r\n\t\t\t\t\tlocal weightObject = childPart:FindFirstChild(\"Weight\")\r\n\t\t\t\t\tif (weightObject == nil) then\r\n\t\t\t\t\t\tanimTable[name][idx].weight = 1\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tanimTable[name][idx].weight = weightObject.Value\r\n\t\t\t\t\tend\r\n\t\t\t\t\tanimTable[name].count = animTable[name].count + 1\r\n\t\t\t\t\tanimTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight\r\n\t\t--\t\t\tprint(name .. \" [\" .. idx .. \"] \" .. animTable[name][idx].anim.AnimationId .. \" (\" .. animTable[name][idx].weight .. \")\")\r\n\t\t\t\t\tidx = idx + 1\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\t\r\n\t\t-- fallback to defaults\r\n\t\tif (animTable[name].count <= 0) then\r\n\t\t\tfor idx, anim in pairs(fileList) do\r\n\t\t\t\tanimTable[name][idx] = {}\r\n\t\t\t\tanimTable[name][idx].anim = Instance.new(\"Animation\")\r\n\t\t\t\tanimTable[name][idx].anim.Name = name\r\n\t\t\t\tanimTable[name][idx].anim.AnimationId = anim.id\r\n\t\t\t\tanimTable[name][idx].weight = anim.weight\r\n\t\t\t\tanimTable[name].count = animTable[name].count + 1\r\n\t\t\t\tanimTable[name].totalWeight = animTable[name].totalWeight + anim.weight\r\n\t--\t\t\tprint(name .. \" [\" .. idx .. \"] \" .. anim.id .. \" (\" .. anim.weight .. \")\")\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\n\t-- Setup animation objects\r\n\tfunction scriptChildModified(child)\r\n\t\tlocal fileList = animNames[child.Name]\r\n\t\tif (fileList ~= nil) then\r\n\t\t\tconfigureAnimationSet(child.Name, fileList)\r\n\t\tend\t\r\n\tend\r\n\t\r\n\tscript.ChildAdded:connect(scriptChildModified)\r\n\tscript.ChildRemoved:connect(scriptChildModified)\r\n\t\r\n\t\r\n\tfor name, fileList in pairs(animNames) do \r\n\t\tconfigureAnimationSet(name, fileList)\r\n\tend\t\r\n\t\r\n\t-- ANIMATION\r\n\t\r\n\t-- declarations\r\n\tlocal toolAnim = \"None\"\r\n\tlocal toolAnimTime = 0\r\n\t\r\n\tlocal jumpAnimTime = 0\r\n\tlocal jumpAnimDuration = 0.3\r\n\t\r\n\tlocal toolTransitionTime = 0.1\r\n\tlocal fallTransitionTime = 0.3\r\n\tlocal jumpMaxLimbVelocity = 0.75\r\n\t\r\n\t-- functions\r\n\t\r\n\tfunction stopAllAnimations()\r\n\t\tlocal oldAnim = currentAnim\r\n\t\r\n\t\t-- return to idle if finishing an emote\r\n\t\tif (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then\r\n\t\t\toldAnim = \"idle\"\r\n\t\tend\r\n\t\r\n\t\tcurrentAnim = \"\"\r\n\t\tcurrentAnimInstance = nil\r\n\t\tif (currentAnimKeyframeHandler ~= nil) then\r\n\t\t\tcurrentAnimKeyframeHandler:disconnect()\r\n\t\tend\r\n\t\r\n\t\tif (currentAnimTrack ~= nil) then\r\n\t\t\tcurrentAnimTrack:Stop()\r\n\t\t\tcurrentAnimTrack:Destroy()\r\n\t\t\tcurrentAnimTrack = nil\r\n\t\tend\r\n\t\treturn oldAnim\r\n\tend\r\n\t\r\n\tfunction setAnimationSpeed(speed)\r\n\t\tif speed ~= currentAnimSpeed then\r\n\t\t\tcurrentAnimSpeed = speed\r\n\t\t\tcurrentAnimTrack:AdjustSpeed(currentAnimSpeed)\r\n\t\tend\r\n\tend\r\n\t\r\n\tfunction keyFrameReachedFunc(frameName)\r\n\t\tif (frameName == \"End\") then\r\n\t\r\n\t\t\tlocal repeatAnim = currentAnim\r\n\t\t\t-- return to idle if finishing an emote\r\n\t\t\tif (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then\r\n\t\t\t\trepeatAnim = \"idle\"\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tlocal animSpeed = currentAnimSpeed\r\n\t\t\tplayAnimation(repeatAnim, 0.0, Humanoid)\r\n\t\t\tsetAnimationSpeed(animSpeed)\r\n\t\tend\r\n\tend\r\n\t\r\n\t-- Preload animations\r\n\tfunction playAnimation(animName, transitionTime, humanoid) \r\n\t\t\t\r\n\t\tlocal roll = math.random(1, animTable[animName].totalWeight) \r\n\t\tlocal origRoll = roll\r\n\t\tlocal idx = 1\r\n\t\twhile (roll > animTable[animName][idx].weight) do\r\n\t\t\troll = roll - animTable[animName][idx].weight\r\n\t\t\tidx = idx + 1\r\n\t\tend\r\n\t--\t\tprint(animName .. \" \" .. idx .. \" [\" .. origRoll .. \"]\")\r\n\t\tlocal anim = animTable[animName][idx].anim\r\n\t\r\n\t\t-- switch animation\t\t\r\n\t\tif (anim ~= currentAnimInstance) then\r\n\t\t\t\r\n\t\t\tif (currentAnimTrack ~= nil) then\r\n\t\t\t\tcurrentAnimTrack:Stop(transitionTime)\r\n\t\t\t\tcurrentAnimTrack:Destroy()\r\n\t\t\tend\r\n\t\r\n\t\t\tcurrentAnimSpeed = 1.0\r\n\t\t\r\n\t\t\t-- load it to the humanoid; get AnimationTrack\r\n\t\t\tcurrentAnimTrack = humanoid:LoadAnimation(anim)\r\n\t\t\tcurrentAnimTrack.Priority = Enum.AnimationPriority.Core\r\n\t\t\t \r\n\t\t\t-- play the animation\r\n\t\t\tcurrentAnimTrack:Play(transitionTime)\r\n\t\t\tcurrentAnim = animName\r\n\t\t\tcurrentAnimInstance = anim\r\n\t\r\n\t\t\t-- set up keyframe name triggers\r\n\t\t\tif (currentAnimKeyframeHandler ~= nil) then\r\n\t\t\t\tcurrentAnimKeyframeHandler:disconnect()\r\n\t\t\tend\r\n\t\t\tcurrentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)\r\n\t\t\t\r\n\t\tend\r\n\t\r\n\tend\r\n\t\r\n\t-------------------------------------------------------------------------------------------\r\n\t-------------------------------------------------------------------------------------------\r\n\t\r\n\tlocal toolAnimName = \"\"\r\n\tlocal toolAnimTrack = nil\r\n\tlocal toolAnimInstance = nil\r\n\tlocal currentToolAnimKeyframeHandler = nil\r\n\t\r\n\tfunction toolKeyFrameReachedFunc(frameName)\r\n\t\tif (frameName == \"End\") then\r\n\t--\t\tprint(\"Keyframe : \".. frameName)\t\r\n\t\t\tplayToolAnimation(toolAnimName, 0.0, Humanoid)\r\n\t\tend\r\n\tend\r\n\t\r\n\t\r\n\tfunction playToolAnimation(animName, transitionTime, humanoid, priority)\t \r\n\t\t\t\r\n\t\t\tlocal roll = math.random(1, animTable[animName].totalWeight) \r\n\t\t\tlocal origRoll = roll\r\n\t\t\tlocal idx = 1\r\n\t\t\twhile (roll > animTable[animName][idx].weight) do\r\n\t\t\t\troll = roll - animTable[animName][idx].weight\r\n\t\t\t\tidx = idx + 1\r\n\t\t\tend\r\n\t--\t\tprint(animName .. \" * \" .. idx .. \" [\" .. origRoll .. \"]\")\r\n\t\t\tlocal anim = animTable[animName][idx].anim\r\n\t\r\n\t\t\tif (toolAnimInstance ~= anim) then\r\n\t\t\t\t\r\n\t\t\t\tif (toolAnimTrack ~= nil) then\r\n\t\t\t\t\ttoolAnimTrack:Stop()\r\n\t\t\t\t\ttoolAnimTrack:Destroy()\r\n\t\t\t\t\ttransitionTime = 0\r\n\t\t\t\tend\r\n\t\t\t\t\t\t\r\n\t\t\t\t-- load it to the humanoid; get AnimationTrack\r\n\t\t\t\ttoolAnimTrack = humanoid:LoadAnimation(anim)\r\n\t\t\t\tif priority then\r\n\t\t\t\t\ttoolAnimTrack.Priority = priority\r\n\t\t\t\tend\r\n\t\t\t\t \r\n\t\t\t\t-- play the animation\r\n\t\t\t\ttoolAnimTrack:Play(transitionTime)\r\n\t\t\t\ttoolAnimName = animName\r\n\t\t\t\ttoolAnimInstance = anim\r\n\t\r\n\t\t\t\tcurrentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)\r\n\t\t\tend\r\n\tend\r\n\t\r\n\tfunction stopToolAnimations()\r\n\t\tlocal oldAnim = toolAnimName\r\n\t\r\n\t\tif (currentToolAnimKeyframeHandler ~= nil) then\r\n\t\t\tcurrentToolAnimKeyframeHandler:disconnect()\r\n\t\tend\r\n\t\r\n\t\ttoolAnimName = \"\"\r\n\t\ttoolAnimInstance = nil\r\n\t\tif (toolAnimTrack ~= nil) then\r\n\t\t\ttoolAnimTrack:Stop()\r\n\t\t\ttoolAnimTrack:Destroy()\r\n\t\t\ttoolAnimTrack = nil\r\n\t\tend\r\n\t\r\n\t\r\n\t\treturn oldAnim\r\n\tend\r\n\t\r\n\t-------------------------------------------------------------------------------------------\r\n\t-------------------------------------------------------------------------------------------\r\n\t\r\n\t\r\n\tfunction onRunning(speed)\r\n\t\tif speed > 0.01 then\r\n\t\t\tplayAnimation(\"walk\", 0.1, Humanoid)\r\n\t\t\tif currentAnimInstance and currentAnimInstance.AnimationId == \"http://www.roblox.com/asset/?id=180426354\" then\r\n\t\t\t\tsetAnimationSpeed(speed / 14.5)\r\n\t\t\tend\r\n\t\t\tpose = \"Running\"\r\n\t\telse\r\n\t\t\tif emoteNames[currentAnim] == nil then\r\n\t\t\t\tplayAnimation(\"idle\", 0.1, Humanoid)\r\n\t\t\t\tpose = \"Standing\"\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\n\tfunction onDied()\r\n\t\tpose = \"Dead\"\r\n\tend\r\n\t\r\n\tfunction onJumping()\r\n\t\tplayAnimation(\"jump\", 0.1, Humanoid)\r\n\t\tjumpAnimTime = jumpAnimDuration\r\n\t\tpose = \"Jumping\"\r\n\tend\r\n\t\r\n\tfunction onClimbing(speed)\r\n\t\tplayAnimation(\"climb\", 0.1, Humanoid)\r\n\t\tsetAnimationSpeed(speed / 12.0)\r\n\t\tpose = \"Climbing\"\r\n\tend\r\n\t\r\n\tfunction onGettingUp()\r\n\t\tpose = \"GettingUp\"\r\n\tend\r\n\t\r\n\tfunction onFreeFall()\r\n\t\tif (jumpAnimTime <= 0) then\r\n\t\t\tplayAnimation(\"fall\", fallTransitionTime, Humanoid)\r\n\t\tend\r\n\t\tpose = \"FreeFall\"\r\n\tend\r\n\t\r\n\tfunction onFallingDown()\r\n\t\tpose = \"FallingDown\"\r\n\tend\r\n\t\r\n\tfunction onSeated()\r\n\t\tpose = \"Seated\"\r\n\tend\r\n\t\r\n\tfunction onPlatformStanding()\r\n\t\tpose = \"PlatformStanding\"\r\n\tend\r\n\t\r\n\tfunction onSwimming(speed)\r\n\t\tif speed > 0 then\r\n\t\t\tpose = \"Running\"\r\n\t\telse\r\n\t\t\tpose = \"Standing\"\r\n\t\tend\r\n\tend\r\n\t\r\n\tfunction getTool()\t\r\n\t\tfor _, kid in ipairs(Figure:GetChildren()) do\r\n\t\t\tif kid.className == \"Tool\" then return kid end\r\n\t\tend\r\n\t\treturn nil\r\n\tend\r\n\t\r\n\tfunction getToolAnim(tool)\r\n\t\tfor _, c in ipairs(tool:GetChildren()) do\r\n\t\t\tif c.Name == \"toolanim\" and c.className == \"StringValue\" then\r\n\t\t\t\treturn c\r\n\t\t\tend\r\n\t\tend\r\n\t\treturn nil\r\n\tend\r\n\t\r\n\tfunction animateTool()\r\n\t\t\r\n\t\tif (toolAnim == \"None\") then\r\n\t\t\tplayToolAnimation(\"toolnone\", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)\r\n\t\t\treturn\r\n\t\tend\r\n\t\r\n\t\tif (toolAnim == \"Slash\") then\r\n\t\t\tplayToolAnimation(\"toolslash\", 0, Humanoid, Enum.AnimationPriority.Action)\r\n\t\t\treturn\r\n\t\tend\r\n\t\r\n\t\tif (toolAnim == \"Lunge\") then\r\n\t\t\tplayToolAnimation(\"toollunge\", 0, Humanoid, Enum.AnimationPriority.Action)\r\n\t\t\treturn\r\n\t\tend\r\n\tend\r\n\t\r\n\tfunction moveSit()\r\n\t\tRightShoulder.MaxVelocity = 0.15\r\n\t\tLeftShoulder.MaxVelocity = 0.15\r\n\t\tRightShoulder:SetDesiredAngle(3.14 /2)\r\n\t\tLeftShoulder:SetDesiredAngle(-3.14 /2)\r\n\t\tRightHip:SetDesiredAngle(3.14 /2)\r\n\t\tLeftHip:SetDesiredAngle(-3.14 /2)\r\n\tend\r\n\t\r\n\tlocal lastTick = 0\r\n\t\r\n\tfunction move(time)\r\n\t\tlocal amplitude = 1\r\n\t\tlocal frequency = 1\r\n\t\t local deltaTime = time - lastTick\r\n\t\t lastTick = time\r\n\t\r\n\t\tlocal climbFudge = 0\r\n\t\tlocal setAngles = false\r\n\t\r\n\t\t if (jumpAnimTime > 0) then\r\n\t\t\t jumpAnimTime = jumpAnimTime - deltaTime\r\n\t\t end\r\n\t\r\n\t\tif (pose == \"FreeFall\" and jumpAnimTime <= 0) then\r\n\t\t\tplayAnimation(\"fall\", fallTransitionTime, Humanoid)\r\n\t\telseif (pose == \"Seated\") then\r\n\t\t\tplayAnimation(\"sit\", 0.5, Humanoid)\r\n\t\t\treturn\r\n\t\telseif (pose == \"Running\") then\r\n\t\t\tplayAnimation(\"walk\", 0.1, Humanoid)\r\n\t\telseif (pose == \"Dead\" or pose == \"GettingUp\" or pose == \"FallingDown\" or pose == \"Seated\" or pose == \"PlatformStanding\") then\r\n\t--\t\tprint(\"Wha \" .. pose)\r\n\t\t\tstopAllAnimations()\r\n\t\t\tamplitude = 0.1\r\n\t\t\tfrequency = 1\r\n\t\t\tsetAngles = true\r\n\t\tend\r\n\t\r\n\t\tif (setAngles) then\r\n\t\t\tlocal desiredAngle = amplitude * math.sin(time * frequency)\r\n\t\r\n\t\t\tRightShoulder:SetDesiredAngle(desiredAngle + climbFudge)\r\n\t\t\tLeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)\r\n\t\t\tRightHip:SetDesiredAngle(-desiredAngle)\r\n\t\t\tLeftHip:SetDesiredAngle(-desiredAngle)\r\n\t\tend\r\n\t\r\n\t\t-- Tool Animation handling\r\n\t\tlocal tool = getTool()\r\n\t\tif tool and tool:FindFirstChild(\"Handle\") then\r\n\t\t\r\n\t\t\tlocal animStringValueObject = getToolAnim(tool)\r\n\t\r\n\t\t\tif animStringValueObject then\r\n\t\t\t\ttoolAnim = animStringValueObject.Value\r\n\t\t\t\t-- message recieved, delete StringValue\r\n\t\t\t\tanimStringValueObject.Parent = nil\r\n\t\t\t\ttoolAnimTime = time + .3\r\n\t\t\tend\r\n\t\r\n\t\t\tif time > toolAnimTime then\r\n\t\t\t\ttoolAnimTime = 0\r\n\t\t\t\ttoolAnim = \"None\"\r\n\t\t\tend\r\n\t\r\n\t\t\tanimateTool()\t\t\r\n\t\telse\r\n\t\t\tstopToolAnimations()\r\n\t\t\ttoolAnim = \"None\"\r\n\t\t\ttoolAnimInstance = nil\r\n\t\t\ttoolAnimTime = 0\r\n\t\tend\r\n\tend\r\n\t\r\n\t\r\n\tlocal events = {}\r\n\tlocal eventHum = Humanoid\r\n\t\r\n\tlocal function onUnhook()\r\n\t\tfor i = 1, #events do\r\n\t\t\tevents[i]:Disconnect()\r\n\t\tend\r\n\t\tevents = {}\r\n\tend\r\n\t\r\n\tlocal function onHook()\r\n\t\tonUnhook()\r\n\t\t\r\n\t\tpose = eventHum.Sit and \"Seated\" or \"Standing\"\r\n\t\t\r\n\t\tevents = {\r\n\t\t\teventHum.Died:connect(onDied),\r\n\t\t\teventHum.Running:connect(onRunning),\r\n\t\t\teventHum.Jumping:connect(onJumping),\r\n\t\t\teventHum.Climbing:connect(onClimbing),\r\n\t\t\teventHum.GettingUp:connect(onGettingUp),\r\n\t\t\teventHum.FreeFalling:connect(onFreeFall),\r\n\t\t\teventHum.FallingDown:connect(onFallingDown),\r\n\t\t\teventHum.Seated:connect(onSeated),\r\n\t\t\teventHum.PlatformStanding:connect(onPlatformStanding),\r\n\t\t\teventHum.Swimming:connect(onSwimming)\r\n\t\t}\r\n\tend\r\n\t\r\n\t\r\n\tonHook()\r\n\tscript:WaitForChild(\"Loaded\").Value = true\r\n\t\r\n\t\r\n\t-- setup emote chat hook\r\n\tgame:GetService(\"Players\").LocalPlayer.Chatted:connect(function(msg)\r\n\t\tlocal emote = \"\"\r\n\t\tif msg == \"/e dance\" then\r\n\t\t\temote = dances[math.random(1, #dances)]\r\n\t\telseif (string.sub(msg, 1, 3) == \"/e \") then\r\n\t\t\temote = string.sub(msg, 4)\r\n\t\telseif (string.sub(msg, 1, 7) == \"/emote \") then\r\n\t\t\temote = string.sub(msg, 8)\r\n\t\tend\r\n\t\t\r\n\t\tif (pose == \"Standing\" and emoteNames[emote] ~= nil) then\r\n\t\t\tplayAnimation(emote, 0.1, Humanoid)\r\n\t\tend\r\n\t\r\n\tend)\r\n\t\r\n\t\r\n\t-- main program\r\n\t\r\n\t-- initialize to idle\r\n\tplayAnimation(\"idle\", 0.1, Humanoid)\r\n\tpose = \"Standing\"\r\n\t\r\n\tspawn(function()\r\n\t\twhile Figure.Parent ~= nil do\r\n\t\t\tlocal _, time = wait(0.1)\r\n\t\t\tmove(time)\r\n\t\tend\r\n\tend)\r\n\t\r\n\treturn {\r\n\t\tonRunning = onRunning, \r\n\t\tonDied = onDied, \r\n\t\tonJumping = onJumping, \r\n\t\tonClimbing = onClimbing, \r\n\t\tonGettingUp = onGettingUp, \r\n\t\tonFreeFall = onFreeFall, \r\n\t\tonFallingDown = onFallingDown, \r\n\t\tonSeated = onSeated, \r\n\t\tonPlatformStanding = onPlatformStanding,\r\n\t\tonHook = onHook,\r\n\t\tonUnhook = onUnhook\r\n\t}\r\n\t\r\n\tend","Loader":"--[[\r\n\t2020 - EgoMoose\r\n\t2020 - MReP lol\r\n--]]\r\n\r\n_G.controllerreqstring = [[\r\nlocal goodRequire = require;\r\nlocal require = function(name)\r\n\tprint(thisScript, name, debug.traceback())\r\n\tif typeof(name) == \"string\" then\r\n\t\tif not cofiG.gravityController[name] then\r\n\t\t\terror(name..\" doesn't exist\")\r\n\t\tend\r\n\t\tlocal a,b = pcall(loadstring(_G.controllerreqstring..'\\n'..cofiG.gravityController[name]));\r\n\r\n\t\tif not a then\r\n\t\t\twarn'error time'\r\n\t\t\terror(name..\" \"..b..\"\\nAT LINE:\\n\"..debug.traceback());\r\n\t\tend;\r\n\r\n\t\treturn b;\r\n\telse\r\n\t\treturn goodRequire(name);\r\n\tend;\r\nend;\r\n]]\r\n\r\nlocal thisScript = \"Loader\"\r\nlocal goodRequire = require;\r\nlocal require = function(name)\r\n\tprint(thisScript, name, debug.traceback())\r\n\tif typeof(name) == \"string\" then\r\n\t\tif not cofiG.gravityController[name] then\r\n\t\t\terror(name..\" doesn't exist\")\r\n\t\tend\r\n\t\tlocal a,b = pcall(loadstring(\"local thisScript = \"..name.._G.controllerreqstring..'\\n'..cofiG.gravityController[name]));\r\n\r\n\t\tif not a then\r\n\t\t\twarn'error time'\r\n\t\t\terror(name..\" \"..b..\"\\nAT LINE:\\n\"..debug.traceback());\r\n\t\tend;\r\n\r\n\t\treturn b;\r\n\telse\r\n\t\treturn goodRequire(name);\r\n\tend;\r\nend;\r\nlocal loaded\r\ndo -- yes\r\n\tlocal MIN_Y = math.rad(-80)\r\n\tlocal MAX_Y = math.rad(80)\r\n\tlocal ZERO = Vector3.new(0, 0, 0)\r\n\tlocal IDENTITYCF = CFrame.new()\r\n\tlocal TERRAIN = game.Workspace.Terrain\r\n\t\r\n\tlocal localPlayer = game:GetService(\"Players\").LocalPlayer\r\n\tlocal playerModule = localPlayer.PlayerScripts:WaitForChild(\"PlayerModule\")\r\n\tlocal cameraModule = playerModule:WaitForChild(\"CameraModule\")\r\n\tlocal baseCameraModule = cameraModule:WaitForChild(\"BaseCamera\")\r\n\tlocal popperCamModule = cameraModule:WaitForChild(\"Poppercam\")\r\n\tlocal utilsModule = cameraModule:WaitForChild(\"CameraUtils\")\r\n\r\n\t-- Functions\r\n\r\n\tlocal function getRotationBetween(u, v, axis)\r\n\t\tlocal dot, uxv = u:Dot(v), u:Cross(v)\r\n\t\tif (dot < -0.99999) then return CFrame.fromAxisAngle(axis, math.pi) end\r\n\t\treturn CFrame.new(0, 0, 0, uxv.x, uxv.y, uxv.z, 1 + dot)\r\n\tend\r\n\r\n\r\n\t-- PopperCam mod\r\n\r\n\tlocal Poppercam = require(popperCamModule)\r\n\tlocal ZoomController = require(cameraModule:WaitForChild(\"ZoomController\"))\r\n\r\n\tfunction Poppercam:Update(renderDt, desiredCameraCFrame, desiredCameraFocus, cameraController)\r\n\t\tlocal rotatedFocus = desiredCameraFocus * (desiredCameraCFrame - desiredCameraCFrame.p)\r\n\t\tlocal extrapolation = self.focusExtrapolator:Step(renderDt, rotatedFocus)\r\n\t\tlocal zoom = ZoomController.Update(renderDt, rotatedFocus, extrapolation)\r\n\t\treturn rotatedFocus*CFrame.new(0, 0, zoom), desiredCameraFocus\r\n\tend\r\n\r\n\t-- BaseCamera mod\r\n\r\n\tlocal BaseCamera = require(baseCameraModule)\r\n\r\n\tBaseCamera.UpCFrame = IDENTITYCF\r\n\t\r\n\tfunction BaseCamera:UpdateUpCFrame(cf)\r\n\t\tself.UpCFrame = cf\r\n\tend\r\n\t\r\n\tfunction BaseCamera:CalculateNewLookCFrame(suppliedLookVector)\r\n\t\tlocal currLookVector = suppliedLookVector or self:GetCameraLookVector()\r\n\t\tcurrLookVector = self.UpCFrame:VectorToObjectSpace(currLookVector)\r\n\t\t\r\n\t\tlocal currPitchAngle = math.asin(currLookVector.y)\r\n\t\tlocal yTheta = math.clamp(self.rotateInput.y, -MAX_Y + currPitchAngle, -MIN_Y + currPitchAngle)\r\n\t\tlocal constrainedRotateInput = Vector2.new(self.rotateInput.x, yTheta)\r\n\t\tlocal startCFrame = CFrame.new(ZERO, currLookVector)\r\n\t\tlocal newLookCFrame = CFrame.Angles(0, -constrainedRotateInput.x, 0) * startCFrame * CFrame.Angles(-constrainedRotateInput.y,0,0)\r\n\t\t\r\n\t\treturn newLookCFrame\r\n\tend\r\n\r\n\t-- Camera mod\r\n\r\n\tlocal Camera = require(cameraModule)\r\n\r\n\tlocal lastUpCFrame = IDENTITYCF\r\n\t\r\n\tCamera.UpVector = Vector3.new(0, 1, 0)\r\n\tCamera.TransitionRate = 0.15\r\n\tCamera.UpCFrame = IDENTITYCF\r\n\t\r\n\tfunction Camera:GetUpVector(oldUpVector)\r\n\t\treturn oldUpVector\r\n\tend\r\n\t\r\n\tfunction Camera:CalculateUpCFrame()\r\n\t\tlocal oldUpVector = self.UpVector\r\n\t\tlocal newUpVector = self:GetUpVector(oldUpVector)\r\n\t\t\r\n\t\tlocal backup = game.Workspace.CurrentCamera.CFrame.RightVector\r\n\t\tlocal transitionCF = getRotationBetween(oldUpVector, newUpVector, backup)\r\n\t\tlocal vecSlerpCF = IDENTITYCF:Lerp(transitionCF, self.TransitionRate)\r\n\t\t\r\n\t\tself.UpVector = vecSlerpCF * oldUpVector\r\n\t\tself.UpCFrame = vecSlerpCF * self.UpCFrame\r\n\t\t\r\n\t\tlastUpCFrame = self.UpCFrame\r\n\tend\r\n\t\r\n\tfunction Camera:Update(dt)\r\n\t\tif self.activeCameraController then\t\r\n\t\t\tlocal newCameraCFrame, newCameraFocus = self.activeCameraController:Update(dt)\r\n\t\t\tself.activeCameraController:ApplyVRTransform()\r\n\t\t\t\r\n\t\t\tself:CalculateUpCFrame()\r\n\t\t\tself.activeCameraController:UpdateUpCFrame(self.UpCFrame)\r\n\t\t\t\r\n\t\t\tlocal offset = newCameraFocus:Inverse() * newCameraCFrame\r\n\t\t\tnewCameraCFrame = newCameraFocus * self.UpCFrame * offset\r\n\t\t\t\r\n\t\t\tif (self.activeCameraController.lastCameraTransform) then\r\n\t\t\t\tself.activeCameraController.lastCameraTransform = newCameraCFrame\r\n\t\t\t\tself.activeCameraController.lastCameraFocus = newCameraFocus\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tif self.activeOcclusionModule then\r\n\t\t\t\tnewCameraCFrame, newCameraFocus = self.activeOcclusionModule:Update(dt, newCameraCFrame, newCameraFocus)\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tgame.Workspace.CurrentCamera.CFrame = newCameraCFrame\r\n\t\t\tgame.Workspace.CurrentCamera.Focus = newCameraFocus\r\n\t\t\t\r\n\t\t\tif self.activeTransparencyController then\r\n\t\t\t\tself.activeTransparencyController:Update()\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\n\r\n--\r\n\r\n\tlocal Utils = require(utilsModule)\r\n\r\n\tfunction Utils.GetAngleBetweenXZVectors(v1, v2)\r\n\t\tlocal upCFrame = lastUpCFrame -- this is kind of lame, but it works\r\n\t\tv1 = upCFrame:VectorToObjectSpace(v1)\r\n\t\tv2 = upCFrame:VectorToObjectSpace(v2)\r\n\t\treturn math.atan2(v2.X*v1.Z-v2.Z*v1.X, v2.X*v1.X+v2.Z*v1.Z)\r\n\tend\r\n\r\n\t--\r\n\r\n\tloaded = Instance.new('BoolValue')\r\n\tloaded.Value = true\r\n\tloaded.Name = \"Loaded\"\r\n\tloaded.Parent = localPlayer.PlayerScripts:WaitForChild\"PlayerScriptsLoader\"\r\n\trequire(playerModule)\r\nend\r\n\r\nlocal RUNSERVICE = game:GetService(\"RunService\")\r\n\r\nRUNSERVICE:UnbindFromRenderStep(\"GravityStep\")\r\n\r\nlocal GravityController = require(\"GravityController\")\r\nlocal Controller = GravityController.new(game.Players.LocalPlayer)\r\n\r\nlocal RADIUS = 2\r\nlocal HEIGHT = 5\r\nlocal ZERO = Vector3.new(0, 0, 0)\r\n\r\nfunction Controller:GetGravityUp(oldGravity)\r\n\tif self.Character.Parent ~= workspace then\r\n\t\tloaded:Destroy()\r\n\t\tself:Destroy()\r\n\tend\r\n\tlocal hrpCF = self.HRP.CFrame\r\n\t\r\n\tlocal ray = Ray.new(hrpCF.p, -5*oldGravity)\r\n\tlocal hit, pos, normal = workspace:FindPartOnRay(ray, self.Character)\r\n\t\r\n\tlocal normalSum = ZERO\r\n\tlocal normalCount = 0\r\n\t\r\n\tif (hit) then\r\n\t\tfor i = 0, 350, 10 do\r\n\t\t\tlocal r = math.rad(i)\r\n\t\t\tlocal x, y = math.cos(r)*RADIUS, math.sin(r)*RADIUS\r\n\t\t\tlocal origin = hrpCF * Vector3.new(y, 0, x)\r\n\t\t\tlocal opposite = hrpCF * Vector3.new(-y, -HEIGHT, -x)\r\n\t\t\t\r\n\t\t\tlocal ray = Ray.new(origin, opposite - origin)\r\n\t\t\tlocal hit, pos, normal = workspace:FindPartOnRay(ray, self.Character)\r\n\t\t\t\r\n\t\t\tif (hit) then\r\n\t\t\t\tnormalCount = normalCount + 1\r\n\t\t\t\tnormalSum = normalSum + normal\r\n\t\t\tend\r\n\t\tend\r\n\t\t\r\n\t\tif (normalSum ~= ZERO) then\r\n\t\t\treturn (normalSum / normalCount).Unit\r\n\t\tend\r\n\t\treturn normal\r\n\tend\r\n\t\r\n\treturn oldGravity\r\nend\r\n","Animate.Controller":"local char = game.Players.LocalPlayer.Character\r\nlocal script = char:FindFirstChild'Animate'\r\nscript.Disabled = true\r\n\r\nInstance.new('BindableFunction', script).Name = \"PlayEmote\"\r\nInstance.new('BoolValue', script).Name = \"Loaded\"\r\n\r\nlocal humanoid = script.Parent:WaitForChild(\"Humanoid\")\r\nlocal loaded = script:WaitForChild(\"Loaded\")\r\n\r\nlocal animFuncs = {}\r\nif (humanoid.RigType == Enum.HumanoidRigType.R6) then\r\n\tanimFuncs = require(\"Animate.R6\")(script)\r\nelse\r\n\tanimFuncs = require(\"Animate.R15\")(script)\r\nend\r\n\r\nif (not loaded.Value) then\r\n\tloaded.Changed:Wait()\r\nend\r\n\r\n_G.animFuncs = animFuncs\r\nreturn animFuncs\r\n","Animate.R15":"return function(script)\r\n\t\r\nlocal Character = script.Parent\r\nlocal Humanoid = Character:WaitForChild(\"Humanoid\")\r\nlocal pose = \"Standing\"\r\n\r\nlocal userNoUpdateOnLoopSuccess, userNoUpdateOnLoopValue = pcall(function() return UserSettings():IsUserFeatureEnabled(\"UserNoUpdateOnLoop\") end)\r\nlocal userNoUpdateOnLoop = userNoUpdateOnLoopSuccess and userNoUpdateOnLoopValue\r\nlocal userAnimationSpeedDampeningSuccess, userAnimationSpeedDampeningValue = pcall(function() return UserSettings():IsUserFeatureEnabled(\"UserAnimationSpeedDampening\") end)\r\nlocal userAnimationSpeedDampening = userAnimationSpeedDampeningSuccess and userAnimationSpeedDampeningValue\r\n\r\nlocal animateScriptEmoteHookFlagExists, animateScriptEmoteHookFlagEnabled = pcall(function()\r\n\treturn UserSettings():IsUserFeatureEnabled(\"UserAnimateScriptEmoteHook\")\r\nend)\r\nlocal FFlagAnimateScriptEmoteHook = animateScriptEmoteHookFlagExists and animateScriptEmoteHookFlagEnabled\r\n\r\nlocal AnimationSpeedDampeningObject = script:FindFirstChild(\"ScaleDampeningPercent\")\r\nlocal HumanoidHipHeight = 2\r\n\r\nlocal EMOTE_TRANSITION_TIME = 0.1\r\n\r\nlocal currentAnim = \"\"\r\nlocal currentAnimInstance = nil\r\nlocal currentAnimTrack = nil\r\nlocal currentAnimKeyframeHandler = nil\r\nlocal currentAnimSpeed = 1.0\r\n\r\nlocal runAnimTrack = nil\r\nlocal runAnimKeyframeHandler = nil\r\n\r\nlocal animTable = {}\r\nlocal animNames = { \r\n\tidle = \t{\t\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507766666\", weight = 1 },\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507766951\", weight = 1 },\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507766388\", weight = 9 }\r\n\t\t\t},\r\n\twalk = \t{ \t\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507777826\", weight = 10 } \r\n\t\t\t}, \r\n\trun = \t{\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507767714\", weight = 10 } \r\n\t\t\t}, \r\n\tswim = \t{\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507784897\", weight = 10 } \r\n\t\t\t}, \r\n\tswimidle = \t{\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507785072\", weight = 10 } \r\n\t\t\t}, \r\n\tjump = \t{\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507765000\", weight = 10 } \r\n\t\t\t}, \r\n\tfall = \t{\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507767968\", weight = 10 } \r\n\t\t\t}, \r\n\tclimb = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507765644\", weight = 10 } \r\n\t\t\t}, \r\n\tsit = \t{\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=2506281703\", weight = 10 } \r\n\t\t\t},\t\r\n\ttoolnone = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507768375\", weight = 10 } \r\n\t\t\t},\r\n\ttoolslash = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=522635514\", weight = 10 } \r\n\t\t\t},\r\n\ttoollunge = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=522638767\", weight = 10 } \r\n\t\t\t},\r\n\twave = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507770239\", weight = 10 } \r\n\t\t\t},\r\n\tpoint = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507770453\", weight = 10 } \r\n\t\t\t},\r\n\tdance = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507771019\", weight = 10 }, \r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507771955\", weight = 10 }, \r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507772104\", weight = 10 } \r\n\t\t\t},\r\n\tdance2 = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507776043\", weight = 10 }, \r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507776720\", weight = 10 }, \r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507776879\", weight = 10 } \r\n\t\t\t},\r\n\tdance3 = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507777268\", weight = 10 }, \r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507777451\", weight = 10 }, \r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507777623\", weight = 10 } \r\n\t\t\t},\r\n\tlaugh = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507770818\", weight = 10 } \r\n\t\t\t},\r\n\tcheer = {\r\n\t\t\t\t{ id = \"http://www.roblox.com/asset/?id=507770677\", weight = 10 } \r\n\t\t\t},\r\n}\r\n\r\n-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote\r\nlocal emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}\r\n\r\nlocal PreloadAnimsUserFlag = false\r\nlocal PreloadedAnims = {}\r\nlocal successPreloadAnim, msgPreloadAnim = pcall(function()\r\n\tPreloadAnimsUserFlag = UserSettings():IsUserFeatureEnabled(\"UserPreloadAnimations\")\r\nend)\r\nif not successPreloadAnim then\r\n\tPreloadAnimsUserFlag = false\r\nend\r\n\r\nmath.randomseed(tick())\r\n\r\nfunction findExistingAnimationInSet(set, anim)\r\n\tif set == nil or anim == nil then\r\n\t\treturn 0\r\n\tend\r\n\t\r\n\tfor idx = 1, set.count, 1 do \r\n\t\tif set[idx].anim.AnimationId == anim.AnimationId then\r\n\t\t\treturn idx\r\n\t\tend\r\n\tend\r\n\t\r\n\treturn 0\r\nend\r\n\r\nfunction configureAnimationSet(name, fileList)\r\n\tif (animTable[name] ~= nil) then\r\n\t\tfor _, connection in pairs(animTable[name].connections) do\r\n\t\t\tconnection:disconnect()\r\n\t\tend\r\n\tend\r\n\tanimTable[name] = {}\r\n\tanimTable[name].count = 0\r\n\tanimTable[name].totalWeight = 0\t\r\n\tanimTable[name].connections = {}\r\n\r\n\tlocal allowCustomAnimations = true\r\n\r\n\tlocal success, msg = pcall(function() allowCustomAnimations = game:GetService(\"StarterPlayer\").AllowCustomAnimations end)\r\n\tif not success then\r\n\t\tallowCustomAnimations = true\r\n\tend\r\n\r\n\t-- check for config values\r\n\tlocal config = script:FindFirstChild(name)\r\n\tif (allowCustomAnimations and config ~= nil) then\r\n\t\ttable.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))\r\n\t\ttable.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))\r\n\t\t\r\n\t\tlocal idx = 0\r\n\t\tfor _, childPart in pairs(config:GetChildren()) do\r\n\t\t\tif (childPart:IsA(\"Animation\")) then\r\n\t\t\t\tlocal newWeight = 1\r\n\t\t\t\tlocal weightObject = childPart:FindFirstChild(\"Weight\")\r\n\t\t\t\tif (weightObject ~= nil) then\r\n\t\t\t\t\tnewWeight = weightObject.Value\r\n\t\t\t\tend\r\n\t\t\t\tanimTable[name].count = animTable[name].count + 1\r\n\t\t\t\tidx = animTable[name].count\r\n\t\t\t\tanimTable[name][idx] = {}\r\n\t\t\t\tanimTable[name][idx].anim = childPart\r\n\t\t\t\tanimTable[name][idx].weight = newWeight\r\n\t\t\t\tanimTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight\r\n\t\t\t\ttable.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))\r\n\t\t\t\ttable.insert(animTable[name].connections, childPart.ChildAdded:connect(function(property) configureAnimationSet(name, fileList) end))\r\n\t\t\t\ttable.insert(animTable[name].connections, childPart.ChildRemoved:connect(function(property) configureAnimationSet(name, fileList) end))\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\n\t-- fallback to defaults\r\n\tif (animTable[name].count <= 0) then\r\n\t\tfor idx, anim in pairs(fileList) do\r\n\t\t\tanimTable[name][idx] = {}\r\n\t\t\tanimTable[name][idx].anim = Instance.new(\"Animation\")\r\n\t\t\tanimTable[name][idx].anim.Name = name\r\n\t\t\tanimTable[name][idx].anim.AnimationId = anim.id\r\n\t\t\tanimTable[name][idx].weight = anim.weight\r\n\t\t\tanimTable[name].count = animTable[name].count + 1\r\n\t\t\tanimTable[name].totalWeight = animTable[name].totalWeight + anim.weight\r\n\t\tend\r\n\tend\r\n\t\r\n\t-- preload anims\r\n\tif PreloadAnimsUserFlag then\r\n\t\tfor i, animType in pairs(animTable) do\r\n\t\t\tfor idx = 1, animType.count, 1 do\r\n\t\t\t\tif PreloadedAnims[animType[idx].anim.AnimationId] == nil then\r\n\t\t\t\t\tHumanoid:LoadAnimation(animType[idx].anim)\r\n\t\t\t\t\tPreloadedAnims[animType[idx].anim.AnimationId] = true\r\n\t\t\t\tend\t\t\t\t\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\nend\r\n\r\n------------------------------------------------------------------------------------------------------------\r\n\r\nfunction configureAnimationSetOld(name, fileList)\r\n\tif (animTable[name] ~= nil) then\r\n\t\tfor _, connection in pairs(animTable[name].connections) do\r\n\t\t\tconnection:disconnect()\r\n\t\tend\r\n\tend\r\n\tanimTable[name] = {}\r\n\tanimTable[name].count = 0\r\n\tanimTable[name].totalWeight = 0\t\r\n\tanimTable[name].connections = {}\r\n\r\n\tlocal allowCustomAnimations = true\r\n\r\n\tlocal success, msg = pcall(function() allowCustomAnimations = game:GetService(\"StarterPlayer\").AllowCustomAnimations end)\r\n\tif not success then\r\n\t\tallowCustomAnimations = true\r\n\tend\r\n\r\n\t-- check for config values\r\n\tlocal config = script:FindFirstChild(name)\r\n\tif (allowCustomAnimations and config ~= nil) then\r\n\t\ttable.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))\r\n\t\ttable.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))\r\n\t\tlocal idx = 1\r\n\t\tfor _, childPart in pairs(config:GetChildren()) do\r\n\t\t\tif (childPart:IsA(\"Animation\")) then\r\n\t\t\t\ttable.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))\r\n\t\t\t\tanimTable[name][idx] = {}\r\n\t\t\t\tanimTable[name][idx].anim = childPart\r\n\t\t\t\tlocal weightObject = childPart:FindFirstChild(\"Weight\")\r\n\t\t\t\tif (weightObject == nil) then\r\n\t\t\t\t\tanimTable[name][idx].weight = 1\r\n\t\t\t\telse\r\n\t\t\t\t\tanimTable[name][idx].weight = weightObject.Value\r\n\t\t\t\tend\r\n\t\t\t\tanimTable[name].count = animTable[name].count + 1\r\n\t\t\t\tanimTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight\r\n\t\t\t\tidx = idx + 1\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\r\n\t-- fallback to defaults\r\n\tif (animTable[name].count <= 0) then\r\n\t\tfor idx, anim in pairs(fileList) do\r\n\t\t\tanimTable[name][idx] = {}\r\n\t\t\tanimTable[name][idx].anim = Instance.new(\"Animation\")\r\n\t\t\tanimTable[name][idx].anim.Name = name\r\n\t\t\tanimTable[name][idx].anim.AnimationId = anim.id\r\n\t\t\tanimTable[name][idx].weight = anim.weight\r\n\t\t\tanimTable[name].count = animTable[name].count + 1\r\n\t\t\tanimTable[name].totalWeight = animTable[name].totalWeight + anim.weight\r\n\t\t\t-- print(name .. \" [\" .. idx .. \"] \" .. anim.id .. \" (\" .. anim.weight .. \")\")\r\n\t\tend\r\n\tend\r\n\t\r\n\t-- preload anims\r\n\tif PreloadAnimsUserFlag then\r\n\t\tfor i, animType in pairs(animTable) do\r\n\t\t\tfor idx = 1, animType.count, 1 do \r\n\t\t\t\tHumanoid:LoadAnimation(animType[idx].anim)\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\nend\r\n\r\n-- Setup animation objects\r\nfunction scriptChildModified(child)\r\n\tlocal fileList = animNames[child.Name]\r\n\tif (fileList ~= nil) then\r\n\t\tconfigureAnimationSet(child.Name, fileList)\r\n\tend\t\r\nend\r\n\r\nscript.ChildAdded:connect(scriptChildModified)\r\nscript.ChildRemoved:connect(scriptChildModified)\r\n\r\n\r\nfor name, fileList in pairs(animNames) do \r\n\tconfigureAnimationSet(name, fileList)\r\nend\t\r\n\r\n-- ANIMATION\r\n\r\n-- declarations\r\nlocal toolAnim = \"None\"\r\nlocal toolAnimTime = 0\r\n\r\nlocal jumpAnimTime = 0\r\nlocal jumpAnimDuration = 0.31\r\n\r\nlocal toolTransitionTime = 0.1\r\nlocal fallTransitionTime = 0.2\r\n\r\nlocal currentlyPlayingEmote = false\r\n\r\n-- functions\r\n\r\nfunction stopAllAnimations()\r\n\tlocal oldAnim = currentAnim\r\n\r\n\t-- return to idle if finishing an emote\r\n\tif (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then\r\n\t\toldAnim = \"idle\"\r\n\tend\r\n\t\r\n\tif FFlagAnimateScriptEmoteHook and currentlyPlayingEmote then\r\n\t\toldAnim = \"idle\"\r\n\t\tcurrentlyPlayingEmote = false\r\n\tend\r\n\r\n\tcurrentAnim = \"\"\r\n\tcurrentAnimInstance = nil\r\n\tif (currentAnimKeyframeHandler ~= nil) then\r\n\t\tcurrentAnimKeyframeHandler:disconnect()\r\n\tend\r\n\r\n\tif (currentAnimTrack ~= nil) then\r\n\t\tcurrentAnimTrack:Stop()\r\n\t\tcurrentAnimTrack:Destroy()\r\n\t\tcurrentAnimTrack = nil\r\n\tend\r\n\r\n\t-- clean up walk if there is one\r\n\tif (runAnimKeyframeHandler ~= nil) then\r\n\t\trunAnimKeyframeHandler:disconnect()\r\n\tend\r\n\t\r\n\tif (runAnimTrack ~= nil) then\r\n\t\trunAnimTrack:Stop()\r\n\t\trunAnimTrack:Destroy()\r\n\t\trunAnimTrack = nil\r\n\tend\r\n\t\r\n\treturn oldAnim\r\nend\r\n\r\nfunction getHeightScale()\r\n\tif Humanoid then\r\n\t\tif not Humanoid.AutomaticScalingEnabled then\r\n\t\t\treturn 1\r\n\t\tend\r\n\t\t\r\n\t\tlocal scale = Humanoid.HipHeight / HumanoidHipHeight\r\n\t\tif userAnimationSpeedDampening then\r\n\t\t\tif AnimationSpeedDampeningObject == nil then\r\n\t\t\t\tAnimationSpeedDampeningObject = script:FindFirstChild(\"ScaleDampeningPercent\")\r\n\t\t\tend\r\n\t\t\tif AnimationSpeedDampeningObject ~= nil then\r\n\t\t\t\tscale = 1 + (Humanoid.HipHeight - HumanoidHipHeight) * AnimationSpeedDampeningObject.Value / HumanoidHipHeight\r\n\t\t\tend\r\n\t\tend\r\n\t\treturn scale\r\n\tend\t\r\n\treturn 1\r\nend\r\n\r\nlocal smallButNotZero = 0.0001\r\nfunction setRunSpeed(speed)\r\n\tlocal speedScaled = speed * 1.25\r\n\tlocal heightScale = getHeightScale()\r\n\tlocal runSpeed = speedScaled / heightScale\r\n\r\n\tif runSpeed ~= currentAnimSpeed then\r\n\t\tif runSpeed < 0.33 then\r\n\t\t\tcurrentAnimTrack:AdjustWeight(1.0)\t\t\r\n\t\t\trunAnimTrack:AdjustWeight(smallButNotZero)\r\n\t\telseif runSpeed < 0.66 then\r\n\t\t\tlocal weight = ((runSpeed - 0.33) / 0.33)\r\n\t\t\tcurrentAnimTrack:AdjustWeight(1.0 - weight + smallButNotZero)\r\n\t\t\trunAnimTrack:AdjustWeight(weight + smallButNotZero)\r\n\t\telse\r\n\t\t\tcurrentAnimTrack:AdjustWeight(smallButNotZero)\r\n\t\t\trunAnimTrack:AdjustWeight(1.0)\r\n\t\tend\r\n\t\tcurrentAnimSpeed = runSpeed\r\n\t\trunAnimTrack:AdjustSpeed(runSpeed)\r\n\t\tcurrentAnimTrack:AdjustSpeed(runSpeed)\r\n\tend\t\r\nend\r\n\r\nfunction setAnimationSpeed(speed)\r\n\tif currentAnim == \"walk\" then\r\n\t\t\tsetRunSpeed(speed)\r\n\telse\r\n\t\tif speed ~= currentAnimSpeed then\r\n\t\t\tcurrentAnimSpeed = speed\r\n\t\t\tcurrentAnimTrack:AdjustSpeed(currentAnimSpeed)\r\n\t\tend\r\n\tend\r\nend\r\n\r\nfunction keyFrameReachedFunc(frameName)\r\n\tif (frameName == \"End\") then\r\n\t\tif currentAnim == \"walk\" then\r\n\t\t\tif userNoUpdateOnLoop == true then\r\n\t\t\t\tif runAnimTrack.Looped ~= true then\r\n\t\t\t\t\trunAnimTrack.TimePosition = 0.0\r\n\t\t\t\tend\r\n\t\t\t\tif currentAnimTrack.Looped ~= true then\r\n\t\t\t\t\tcurrentAnimTrack.TimePosition = 0.0\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\trunAnimTrack.TimePosition = 0.0\r\n\t\t\t\tcurrentAnimTrack.TimePosition = 0.0\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tlocal repeatAnim = currentAnim\r\n\t\t\t-- return to idle if finishing an emote\r\n\t\t\tif (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then\r\n\t\t\t\trepeatAnim = \"idle\"\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tif FFlagAnimateScriptEmoteHook and currentlyPlayingEmote then\r\n\t\t\t\tif currentAnimTrack.Looped then\r\n\t\t\t\t\t-- Allow the emote to loop\r\n\t\t\t\t\treturn\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\t\t\t\trepeatAnim = \"idle\"\r\n\t\t\t\tcurrentlyPlayingEmote = false\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tlocal animSpeed = currentAnimSpeed\r\n\t\t\tplayAnimation(repeatAnim, 0.15, Humanoid)\r\n\t\t\tsetAnimationSpeed(animSpeed)\r\n\t\tend\r\n\tend\r\nend\r\n\r\nfunction rollAnimation(animName)\r\n\tlocal roll = math.random(1, animTable[animName].totalWeight) \r\n\tlocal origRoll = roll\r\n\tlocal idx = 1\r\n\twhile (roll > animTable[animName][idx].weight) do\r\n\t\troll = roll - animTable[animName][idx].weight\r\n\t\tidx = idx + 1\r\n\tend\r\n\treturn idx\r\nend\r\n\r\nlocal function switchToAnim(anim, animName, transitionTime, humanoid)\r\n\t-- switch animation\t\t\r\n\tif (anim ~= currentAnimInstance) then\r\n\t\t\r\n\t\tif (currentAnimTrack ~= nil) then\r\n\t\t\tcurrentAnimTrack:Stop(transitionTime)\r\n\t\t\tcurrentAnimTrack:Destroy()\r\n\t\tend\r\n\r\n\t\tif (runAnimTrack ~= nil) then\r\n\t\t\trunAnimTrack:Stop(transitionTime)\r\n\t\t\trunAnimTrack:Destroy()\r\n\t\t\tif userNoUpdateOnLoop == true then\r\n\t\t\t\trunAnimTrack = nil\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\tcurrentAnimSpeed = 1.0\r\n\t\r\n\t\t-- load it to the humanoid; get AnimationTrack\r\n\t\tcurrentAnimTrack = humanoid:LoadAnimation(anim)\r\n\t\tcurrentAnimTrack.Priority = Enum.AnimationPriority.Core\r\n\t\t \r\n\t\t-- play the animation\r\n\t\tcurrentAnimTrack:Play(transitionTime)\r\n\t\tcurrentAnim = animName\r\n\t\tcurrentAnimInstance = anim\r\n\r\n\t\t-- set up keyframe name triggers\r\n\t\tif (currentAnimKeyframeHandler ~= nil) then\r\n\t\t\tcurrentAnimKeyframeHandler:disconnect()\r\n\t\tend\r\n\t\tcurrentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)\r\n\t\t\r\n\t\t-- check to see if we need to blend a walk/run animation\r\n\t\tif animName == \"walk\" then\r\n\t\t\tlocal runAnimName = \"run\"\r\n\t\t\tlocal runIdx = rollAnimation(runAnimName)\r\n\r\n\t\t\trunAnimTrack = humanoid:LoadAnimation(animTable[runAnimName][runIdx].anim)\r\n\t\t\trunAnimTrack.Priority = Enum.AnimationPriority.Core\r\n\t\t\trunAnimTrack:Play(transitionTime)\t\t\r\n\t\t\t\r\n\t\t\tif (runAnimKeyframeHandler ~= nil) then\r\n\t\t\t\trunAnimKeyframeHandler:disconnect()\r\n\t\t\tend\r\n\t\t\trunAnimKeyframeHandler = runAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)\t\r\n\t\tend\r\n\tend\r\nend\r\n\r\nfunction playAnimation(animName, transitionTime, humanoid) \t\r\n\tlocal idx = rollAnimation(animName)\r\n\tlocal anim = animTable[animName][idx].anim\r\n\r\n\tswitchToAnim(anim, animName, transitionTime, humanoid)\r\n\tcurrentlyPlayingEmote = false\r\nend\r\n\r\nfunction playEmote(emoteAnim, transitionTime, humanoid)\r\n\tswitchToAnim(emoteAnim, emoteAnim.Name, transitionTime, humanoid)\r\n\tcurrentlyPlayingEmote = true\r\nend\r\n\r\n-------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------\r\n\r\nlocal toolAnimName = \"\"\r\nlocal toolAnimTrack = nil\r\nlocal toolAnimInstance = nil\r\nlocal currentToolAnimKeyframeHandler = nil\r\n\r\nfunction toolKeyFrameReachedFunc(frameName)\r\n\tif (frameName == \"End\") then\r\n\t\tplayToolAnimation(toolAnimName, 0.0, Humanoid)\r\n\tend\r\nend\r\n\r\n\r\nfunction playToolAnimation(animName, transitionTime, humanoid, priority)\t \t\t\r\n\t\tlocal idx = rollAnimation(animName)\r\n\t\tlocal anim = animTable[animName][idx].anim\r\n\r\n\t\tif (toolAnimInstance ~= anim) then\r\n\t\t\t\r\n\t\t\tif (toolAnimTrack ~= nil) then\r\n\t\t\t\ttoolAnimTrack:Stop()\r\n\t\t\t\ttoolAnimTrack:Destroy()\r\n\t\t\t\ttransitionTime = 0\r\n\t\t\tend\r\n\t\t\t\t\t\r\n\t\t\t-- load it to the humanoid; get AnimationTrack\r\n\t\t\ttoolAnimTrack = humanoid:LoadAnimation(anim)\r\n\t\t\tif priority then\r\n\t\t\t\ttoolAnimTrack.Priority = priority\r\n\t\t\tend\r\n\t\t\t \r\n\t\t\t-- play the animation\r\n\t\t\ttoolAnimTrack:Play(transitionTime)\r\n\t\t\ttoolAnimName = animName\r\n\t\t\ttoolAnimInstance = anim\r\n\r\n\t\t\tcurrentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)\r\n\t\tend\r\nend\r\n\r\nfunction stopToolAnimations()\r\n\tlocal oldAnim = toolAnimName\r\n\r\n\tif (currentToolAnimKeyframeHandler ~= nil) then\r\n\t\tcurrentToolAnimKeyframeHandler:disconnect()\r\n\tend\r\n\r\n\ttoolAnimName = \"\"\r\n\ttoolAnimInstance = nil\r\n\tif (toolAnimTrack ~= nil) then\r\n\t\ttoolAnimTrack:Stop()\r\n\t\ttoolAnimTrack:Destroy()\r\n\t\ttoolAnimTrack = nil\r\n\tend\r\n\r\n\treturn oldAnim\r\nend\r\n\r\n-------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------\r\n-- STATE CHANGE HANDLERS\r\n\r\nfunction onRunning(speed)\r\n\tif speed > 0.75 then\r\n\t\tlocal scale = 16.0\r\n\t\tplayAnimation(\"walk\", 0.2, Humanoid)\r\n\t\tsetAnimationSpeed(speed / scale)\r\n\t\tpose = \"Running\"\r\n\telse\r\n\t\tif emoteNames[currentAnim] == nil and not currentlyPlayingEmote then\r\n\t\t\tplayAnimation(\"idle\", 0.2, Humanoid)\r\n\t\t\tpose = \"Standing\"\r\n\t\tend\r\n\tend\r\nend\r\n\r\nfunction onDied()\r\n\tpose = \"Dead\"\r\nend\r\n\r\nfunction onJumping()\r\n\tplayAnimation(\"jump\", 0.1, Humanoid)\r\n\tjumpAnimTime = jumpAnimDuration\r\n\tpose = \"Jumping\"\r\nend\r\n\r\nfunction onClimbing(speed)\r\n\tlocal scale = 5.0\r\n\tplayAnimation(\"climb\", 0.1, Humanoid)\r\n\tsetAnimationSpeed(speed / scale)\r\n\tpose = \"Climbing\"\r\nend\r\n\r\nfunction onGettingUp()\r\n\tpose = \"GettingUp\"\r\nend\r\n\r\nfunction onFreeFall()\r\n\tif (jumpAnimTime <= 0) then\r\n\t\tplayAnimation(\"fall\", fallTransitionTime, Humanoid)\r\n\tend\r\n\tpose = \"FreeFall\"\r\nend\r\n\r\nfunction onFallingDown()\r\n\tpose = \"FallingDown\"\r\nend\r\n\r\nfunction onSeated()\r\n\tpose = \"Seated\"\r\nend\r\n\r\nfunction onPlatformStanding()\r\n\tpose = \"PlatformStanding\"\r\nend\r\n\r\n-------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------\r\n\r\nfunction onSwimming(speed)\r\n\tif speed > 1.00 then\r\n\t\tlocal scale = 10.0\r\n\t\tplayAnimation(\"swim\", 0.4, Humanoid)\r\n\t\tsetAnimationSpeed(speed / scale)\r\n\t\tpose = \"Swimming\"\r\n\telse\r\n\t\tplayAnimation(\"swimidle\", 0.4, Humanoid)\r\n\t\tpose = \"Standing\"\r\n\tend\r\nend\r\n\r\nfunction animateTool()\r\n\tif (toolAnim == \"None\") then\r\n\t\tplayToolAnimation(\"toolnone\", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)\r\n\t\treturn\r\n\tend\r\n\r\n\tif (toolAnim == \"Slash\") then\r\n\t\tplayToolAnimation(\"toolslash\", 0, Humanoid, Enum.AnimationPriority.Action)\r\n\t\treturn\r\n\tend\r\n\r\n\tif (toolAnim == \"Lunge\") then\r\n\t\tplayToolAnimation(\"toollunge\", 0, Humanoid, Enum.AnimationPriority.Action)\r\n\t\treturn\r\n\tend\r\nend\r\n\r\nfunction getToolAnim(tool)\r\n\tfor _, c in ipairs(tool:GetChildren()) do\r\n\t\tif c.Name == \"toolanim\" and c.className == \"StringValue\" then\r\n\t\t\treturn c\r\n\t\tend\r\n\tend\r\n\treturn nil\r\nend\r\n\r\nlocal lastTick = 0\r\n\r\nfunction stepAnimate(currentTime)\r\n\tlocal amplitude = 1\r\n\tlocal frequency = 1\r\n \tlocal deltaTime = currentTime - lastTick\r\n \tlastTick = currentTime\r\n\r\n\tlocal climbFudge = 0\r\n\tlocal setAngles = false\r\n\r\n \tif (jumpAnimTime > 0) then\r\n \t\tjumpAnimTime = jumpAnimTime - deltaTime\r\n \tend\r\n\r\n\tif (pose == \"FreeFall\" and jumpAnimTime <= 0) then\r\n\t\tplayAnimation(\"fall\", fallTransitionTime, Humanoid)\r\n\telseif (pose == \"Seated\") then\r\n\t\tplayAnimation(\"sit\", 0.5, Humanoid)\r\n\t\treturn\r\n\telseif (pose == \"Running\") then\r\n\t\tplayAnimation(\"walk\", 0.2, Humanoid)\r\n\telseif (pose == \"Dead\" or pose == \"GettingUp\" or pose == \"FallingDown\" or pose == \"Seated\" or pose == \"PlatformStanding\") then\r\n\t\tstopAllAnimations()\r\n\t\tamplitude = 0.1\r\n\t\tfrequency = 1\r\n\t\tsetAngles = true\r\n\tend\r\n\r\n\t-- Tool Animation handling\r\n\tlocal tool = Character:FindFirstChildOfClass(\"Tool\")\r\n\tif tool and tool:FindFirstChild(\"Handle\") then\r\n\t\tlocal animStringValueObject = getToolAnim(tool)\r\n\r\n\t\tif animStringValueObject then\r\n\t\t\ttoolAnim = animStringValueObject.Value\r\n\t\t\t-- message recieved, delete StringValue\r\n\t\t\tanimStringValueObject.Parent = nil\r\n\t\t\ttoolAnimTime = currentTime + .3\r\n\t\tend\r\n\r\n\t\tif currentTime > toolAnimTime then\r\n\t\t\ttoolAnimTime = 0\r\n\t\t\ttoolAnim = \"None\"\r\n\t\tend\r\n\r\n\t\tanimateTool()\t\t\r\n\telse\r\n\t\tstopToolAnimations()\r\n\t\ttoolAnim = \"None\"\r\n\t\ttoolAnimInstance = nil\r\n\t\ttoolAnimTime = 0\r\n\tend\r\nend\r\n\r\n-- connect events\r\n\r\nlocal events = {}\r\nlocal eventHum = Humanoid\r\n\r\nlocal function onUnhook()\r\n\tfor i = 1, #events do\r\n\t\tevents[i]:Disconnect()\r\n\tend\r\n\tevents = {}\r\nend\r\n\r\nlocal function onHook()\r\n\tonUnhook()\r\n\t\r\n\tpose = eventHum.Sit and \"Seated\" or \"Standing\"\r\n\t\r\n\tevents = {\r\n\t\teventHum.Died:connect(onDied),\r\n\t\teventHum.Running:connect(onRunning),\r\n\t\teventHum.Jumping:connect(onJumping),\r\n\t\teventHum.Climbing:connect(onClimbing),\r\n\t\teventHum.GettingUp:connect(onGettingUp),\r\n\t\teventHum.FreeFalling:connect(onFreeFall),\r\n\t\teventHum.FallingDown:connect(onFallingDown),\r\n\t\teventHum.Seated:connect(onSeated),\r\n\t\teventHum.PlatformStanding:connect(onPlatformStanding),\r\n\t\teventHum.Swimming:connect(onSwimming)\r\n\t}\r\nend\r\n\r\n\r\nonHook()\r\nscript:WaitForChild(\"Loaded\").Value = true\r\n\r\n-- setup emote chat hook\r\ngame:GetService(\"Players\").LocalPlayer.Chatted:connect(function(msg)\r\n\tlocal emote = \"\"\r\n\tif (string.sub(msg, 1, 3) == \"/e \") then\r\n\t\temote = string.sub(msg, 4)\r\n\telseif (string.sub(msg, 1, 7) == \"/emote \") then\r\n\t\temote = string.sub(msg, 8)\r\n\tend\r\n\t\r\n\tif (pose == \"Standing\" and emoteNames[emote] ~= nil) then\r\n\t\tplayAnimation(emote, EMOTE_TRANSITION_TIME, Humanoid)\r\n\tend\r\nend)\r\n\r\n-- emote bindable hook\r\nif FFlagAnimateScriptEmoteHook then\r\n\tscript:WaitForChild(\"PlayEmote\").OnInvoke = function(emote)\r\n\t\t-- Only play emotes when idling\r\n\t\tif pose ~= \"Standing\" then\r\n\t\t\treturn\r\n\t\tend\r\n\t\r\n\t\tif emoteNames[emote] ~= nil then\r\n\t\t\t-- Default emotes\r\n\t\t\tplayAnimation(emote, EMOTE_TRANSITION_TIME, Humanoid)\r\n\t\t\t\r\n\t\t\treturn true\r\n\t\telseif typeof(emote) == \"Instance\" and emote:IsA(\"Animation\") then\r\n\t\t\t-- Non-default emotes\r\n\t\t\tplayEmote(emote, EMOTE_TRANSITION_TIME, Humanoid)\r\n\t\t\treturn true\r\n\t\tend\r\n\t\t\r\n\t\t-- Return false to indicate that the emote could not be played\r\n\t\treturn false\r\n\tend\r\nend\r\n\r\n-- initialize to idle\r\nplayAnimation(\"idle\", 0.1, Humanoid)\r\npose = \"Standing\"\r\n\r\n-- loop to handle timed state transitions and tool animations\r\nspawn(function()\r\n\twhile Character.Parent ~= nil do\r\n\t\tlocal _, currentGameTime = wait(0.1)\r\n\t\tstepAnimate(currentGameTime)\r\n\tend\r\nend)\r\n\r\nreturn {\r\n\tonRunning = onRunning, \r\n\tonDied = onDied, \r\n\tonJumping = onJumping, \r\n\tonClimbing = onClimbing, \r\n\tonGettingUp = onGettingUp, \r\n\tonFreeFall = onFreeFall, \r\n\tonFallingDown = onFallingDown, \r\n\tonSeated = onSeated, \r\n\tonPlatformStanding = onPlatformStanding,\r\n\tonHook = onHook,\r\n\tonUnhook = onUnhook\r\n}\r\n\r\nend","GravityController":"--[[\r\n\t\r\nThis is a class that provides custom physics that allows things like walking upside down or on planets, etc\r\n\r\nThis is where the scripts should be placed\r\n\t- GravityController (ReplicatedStorage)\r\n\t- Animate (StarterCharacterScripts)\r\n\t- PlayerScriptsLoaded (StaterPlayerScripts)\r\n\r\nAPI:\r\n\r\nConstructors:\r\n\tGravityController.new(Player player)\r\n\t\t> Creates a GravityController object for the given player.\r\n\r\nMethods:\r\n\tGravityController:Destroy()\r\n\t\t> Destroys the GravityController object. This returns the player back to the standard character controller.\r\n\tGravityController:GetGravityUp(Vector3 oldGravity)\r\n\t\t> This method should be set by the developer and should return the gravity up vector that the developer would like \r\n\t\t to be applied to the player's character\r\n\t\r\nProperties:\r\n\tGravityController.GravityUp\r\n\t\t> The current gravity up vector that is being applied to the player\r\n\t\r\n\r\nEnjoy!\r\n- EgoMoose\r\n\r\n--]]\r\n\r\nlocal ZERO = Vector3.new(0, 0, 0)\r\nlocal UNIT_X = Vector3.new(1, 0, 0)\r\nlocal UNIT_Y = Vector3.new(0, 1, 0)\r\nlocal UNIT_Z = Vector3.new(0, 0, 1)\r\nlocal VEC_XY = Vector3.new(1, 0, 1)\r\n\r\nlocal IDENTITYCF = CFrame.new()\r\n\r\nlocal JUMPMODIFIER = 1.2\r\nlocal TRANSITION = 0.15\r\nlocal WALKF = 200 / 3\r\n\r\nlocal UIS = game:GetService(\"UserInputService\")\r\nlocal RUNSERVICE = game:GetService(\"RunService\")\r\n\r\nlocal InitObjects = require(\"InitObjects\")\r\nlocal CameraModifier = require(\"CameraModifier\")\r\nlocal AnimationHandler = require(\"AnimationHandler\")\r\nlocal StateTracker = require(\"StateTracker\")\r\n\r\n-- Class\r\n\r\nlocal GravityController = {}\r\nGravityController.__index = GravityController\r\n\r\n-- Private Functions\r\n\r\nlocal function getRotationBetween(u, v, axis)\r\n\tlocal dot, uxv = u:Dot(v), u:Cross(v)\r\n\tif (dot < -0.99999) then return CFrame.fromAxisAngle(axis, math.pi) end\r\n\treturn CFrame.new(0, 0, 0, uxv.x, uxv.y, uxv.z, 1 + dot)\r\nend\r\n\r\nlocal function lookAt(pos, forward, up)\r\n\tlocal r = forward:Cross(up)\r\n\tlocal u = r:Cross(forward)\r\n\treturn CFrame.fromMatrix(pos, r.Unit, u.Unit)\r\nend\r\n\r\nlocal function getMass(array)\r\n\tlocal mass = 0\r\n\tfor _, part in next, array do\r\n\t\tif (part:IsA(\"BasePart\")) then\r\n\t\t\tmass = mass + part:GetMass()\r\n\t\tend\r\n\tend\r\n\treturn mass\r\nend\r\n\r\n-- Public Constructor\r\n\r\nfunction GravityController.new(player)\r\n\tlocal self = setmetatable({}, GravityController)\r\n\r\n\t-- Camera\r\n\tlocal loaded = player.PlayerScripts:WaitForChild(\"PlayerScriptsLoader\"):WaitForChild(\"Loaded\")\r\n\tif (not loaded.Value) then\r\n\t\tloaded.Changed:Wait()\r\n\tend\r\n\t\r\n\tlocal playerModule = require(player.PlayerScripts:WaitForChild(\"PlayerModule\"))\r\n\tself.Controls = playerModule:GetControls()\r\n\tself.Camera = playerModule:GetCameras()\r\n\t\r\n\tself.CameraModifier = CameraModifier.new(player)\r\n\t\r\n\t-- Player and character\r\n\tself.Player = player\r\n\tself.Character = player.Character\r\n\tself.Humanoid = player.Character:WaitForChild(\"Humanoid\")\r\n\tself.HRP = player.Character:WaitForChild(\"HumanoidRootPart\")\r\n\t\r\n\t-- Animation\r\n\tself.AnimationHandler = AnimationHandler.new(self.Humanoid, self.Character:WaitForChild(\"Animate\"))\r\n\tself.AnimationHandler:EnableDefault(false)\r\n\t\r\n\t--local soundState = player.PlayerScripts:WaitForChild(\"RbxCharacterSounds\"):WaitForChild(\"SetState\")\r\n\t\r\n\tself.StateTracker = StateTracker.new(self.Humanoid)\r\n\tself.StateTracker.Changed:Connect(function(name, speed)\r\n\t\tself.AnimationHandler:Run(name, speed)\r\n\tend)\r\n\t\r\n\t-- Collider and forces\r\n\tlocal collider, gyro, vForce, floor = InitObjects(self)\r\n\t\r\n\tfloor.Touched:Connect(function() end)\r\n\t\r\n\tself.Collider = collider\r\n\tself.VForce = vForce\r\n\tself.Gyro = gyro\r\n\tself.Floor = floor\r\n\t\r\n\t-- Attachment to parts\r\n\tself.LastPart = workspace.Terrain\r\n\tself.LastPartCFrame = IDENTITYCF\r\n\t\r\n\t-- Gravity properties\r\n\tself.GravityUp = UNIT_Y\r\n\tself.Ignores = {self.Character}\r\n\t\r\n\tfunction self.Camera.GetUpVector(this, oldUpVector)\r\n\t\treturn self.GravityUp\r\n\tend\r\n\t\r\n\t-- Events etc\r\n\tself.Humanoid.PlatformStand = true\r\n\t\r\n\tself.CharacterMass = getMass(self.Character:GetDescendants())\r\n\tself.Character.AncestryChanged:Connect(function() self.CharacterMass = getMass(self.Character:GetDescendants()) end)\r\n\t\r\n\tself.JumpCon = UIS.JumpRequest:Connect(function() self:OnJumpRequest() end)\r\n\tself.DeathCon = self.Humanoid.Died:Connect(function() self:Destroy() end)\r\n\tself.SeatCon = self.Humanoid.Seated:Connect(function(active) if (active) then self:Destroy() end end)\r\n\tself.HeartCon = RUNSERVICE.Heartbeat:Connect(function(dt) self:OnHeartbeatStep(dt) end)\r\n\tRUNSERVICE:BindToRenderStep(\"GravityStep\", Enum.RenderPriority.Input.Value + 1, function(dt) self:OnGravityStep(dt) end)\r\n\t\r\n\t\r\n\treturn self\r\nend\r\n\r\n-- Public Methods\r\n\r\nfunction GravityController:Destroy()\r\n\tfunction self.Camera:GetUpVector()\r\n\t\treturn Vector3.new(0,1,0)\r\n\tend\r\n\t\r\n\tself.JumpCon:Disconnect()\r\n\tself.DeathCon:Disconnect()\r\n\tself.SeatCon:Disconnect()\r\n\tself.HeartCon:Disconnect()\r\n\t\r\n\tRUNSERVICE:UnbindFromRenderStep(\"GravityStep\")\r\n\t\r\n\tself.CameraModifier:Destroy()\r\n\tself.Collider:Destroy()\r\n\tself.VForce:Destroy()\r\n\tself.Gyro:Destroy()\r\n\tself.StateTracker:Destroy()\r\n\t\r\n\tself.Humanoid.PlatformStand = false\r\n\tself.AnimationHandler:EnableDefault(true)\r\n\t\r\n\tself.GravityUp = UNIT_Y\r\nend\r\n\r\nfunction GravityController:GetGravityUp(oldGravity)\r\n\treturn oldGravity\r\nend\r\n\r\nfunction GravityController:IsGrounded()\r\n\tlocal parts = self.Floor:GetTouchingParts()\r\n\tfor _, part in next, parts do\r\n\t\tif (not part:IsDescendantOf(self.Character)) then\r\n\t\t\treturn true\r\n\t\tend\r\n\tend\r\n\treturn false\r\nend\r\n\r\nfunction GravityController:OnJumpRequest()\r\n\tif (not self.StateTracker.Jumped and self:IsGrounded()) then\r\n\t\tlocal hrpVel = self.HRP.Velocity\r\n\t\tself.HRP.Velocity = hrpVel + self.GravityUp*self.Humanoid.JumpPower*JUMPMODIFIER\r\n\t\tself.StateTracker:RequestedJump()\r\n\tend\r\nend\r\n\r\nfunction GravityController:GetMoveVector()\r\n\treturn self.Controls:GetMoveVector()\r\nend\r\n\r\nfunction GravityController:OnHeartbeatStep(dt)\r\n\tlocal ray = Ray.new(self.Collider.Position, -1.1*self.GravityUp)\r\n\tlocal hit, pos, normal = workspace:FindPartOnRayWithIgnoreList(ray, self.Ignores)\r\n\tlocal lastPart = self.LastPart\r\n\t\r\n\tif (hit and lastPart and lastPart == hit) then\r\n\t\tlocal offset = self.LastPartCFrame:ToObjectSpace(self.HRP.CFrame)\r\n\t\tself.HRP.CFrame = hit.CFrame:ToWorldSpace(offset)\r\n\tend\r\n\t\r\n\tself.LastPart = hit\r\n\tself.LastPartCFrame = hit and hit.CFrame\r\nend\r\n\r\nfunction GravityController:OnGravityStep(dt)\r\n\t-- update gravity up vector\r\n\tlocal oldGravity = self.GravityUp\r\n\tlocal newGravity = self:GetGravityUp(oldGravity)\r\n\t\r\n\tlocal rotation = getRotationBetween(oldGravity, newGravity, workspace.CurrentCamera.CFrame.RightVector)\r\n\trotation = IDENTITYCF:Lerp(rotation, TRANSITION)\r\n\t\r\n\tself.GravityUp = rotation * oldGravity\r\n\t\r\n\t-- get world move vector\r\n\tlocal camCF = workspace.CurrentCamera.CFrame\r\n\tlocal fDot = camCF.LookVector:Dot(newGravity)\r\n\tlocal cForward = math.abs(fDot) > 0.5 and -math.sign(fDot)*camCF.UpVector or camCF.LookVector\r\n\t\r\n\tlocal left = cForward:Cross(-newGravity).Unit\r\n\tlocal forward = -left:Cross(newGravity).Unit\r\n\t\r\n\tlocal move = self:GetMoveVector()\r\n\tlocal worldMove = forward*move.z - left*move.x\r\n\tworldMove = worldMove:Dot(worldMove) > 1 and worldMove.Unit or worldMove\r\n\t\r\n\tlocal isInputMoving = worldMove:Dot(worldMove) > 0\r\n\t\r\n\t-- get the desired character cframe\r\n\tlocal hrpCFLook = self.HRP.CFrame.LookVector\r\n\tlocal charF = hrpCFLook:Dot(forward)*forward + hrpCFLook:Dot(left)*left\r\n\tlocal charR = charF:Cross(newGravity).Unit\r\n\tlocal newCharCF = CFrame.fromMatrix(ZERO, charR, newGravity, -charF)\r\n\t\r\n\tlocal newCharRotation = IDENTITYCF\r\n\tif (isInputMoving) then\r\n\t\tnewCharRotation = IDENTITYCF:Lerp(getRotationBetween(charF, worldMove, newGravity), 0.7)\t\r\n\tend\r\n\t\r\n\t-- calculate forces\r\n\tlocal g = workspace.Gravity\r\n\tlocal gForce = g * self.CharacterMass * (UNIT_Y - newGravity)\r\n\t\r\n\tlocal cVelocity = self.HRP.Velocity\r\n\tlocal tVelocity = self.Humanoid.WalkSpeed * worldMove\r\n\tlocal gVelocity = cVelocity:Dot(newGravity)*newGravity\r\n\tlocal hVelocity = cVelocity - gVelocity\r\n\t\r\n\tif (hVelocity:Dot(hVelocity) < 1) then\r\n\t\thVelocity = ZERO\r\n\tend\r\n\t\r\n\tlocal dVelocity = tVelocity - hVelocity\r\n\tlocal walkForceM = math.min(10000, WALKF * self.CharacterMass * dVelocity.Magnitude)\r\n\tlocal walkForce = walkForceM > 0 and dVelocity.Unit*walkForceM or ZERO\r\n\t\r\n\t-- mouse lock\r\n\tlocal charRotation = newCharRotation * newCharCF\r\n\tif (self.CameraModifier.IsCamLocked) then\r\n\t\tlocal lv = workspace.CurrentCamera.CFrame.LookVector\r\n\t\tlocal hlv = lv - charRotation.UpVector:Dot(lv)*charRotation.UpVector\r\n\t\tcharRotation = lookAt(ZERO, hlv, charRotation.UpVector)\r\n\tend\r\n\r\n\t-- get state\r\n\tself.StateTracker:OnStep(self.GravityUp, self:IsGrounded(), isInputMoving)\r\n\r\n\t-- update values\r\n\tself.VForce.Force = walkForce + gForce\r\n\tself.Gyro.CFrame = charRotation\r\nend\r\n\r\n\r\nreturn GravityController","InitObjects":"local script = _G.initObjects\r\n\r\nif not script then\r\n local partsWithId = {}\r\n local awaitRef = {}\r\n\r\n local root = {\r\n ID = 0;\r\n Type = \"ModuleScript\";\r\n Properties = {\r\n Name = \"InitObjects\";\r\n };\r\n Children = {\r\n {\r\n ID = 1;\r\n Type = \"Part\";\r\n Properties = {\r\n BottomSurface = Enum.SurfaceType.Smooth;\r\n Color = Color3.new(41/51,41/51,41/51);\r\n CFrame = CFrame.new(46,3.4996271133423,6,1,0,0,0,1,0,0,0,1);\r\n CustomPhysicalProperties = PhysicalProperties.new(0.69999998807907,0,0,1,100);\r\n Name = \"Sphere\";\r\n Transparency = 1;\r\n brickColor = BrickColor.new(41/51,41/51,41/51);\r\n Position = Vector3.new(46,3.4996271133423,6);\r\n BrickColor = BrickColor.new(41/51,41/51,41/51);\r\n Size = Vector3.new(2,2,2);\r\n Shape = Enum.PartType.Ball;\r\n TopSurface = Enum.SurfaceType.Smooth;\r\n };\r\n Children = {};\r\n };\r\n {\r\n ID = 2;\r\n Type = \"BodyGyro\";\r\n Properties = {\r\n P = 25000;\r\n MaxTorque = Vector3.new(100000,100000,100000);\r\n maxTorque = Vector3.new(100000,100000,100000);\r\n };\r\n Children = {};\r\n };\r\n {\r\n ID = 3;\r\n Type = \"VectorForce\";\r\n Properties = {\r\n RelativeTo = Enum.ActuatorRelativeTo.World;\r\n Force = Vector3.new();\r\n ApplyAtCenterOfMass = true;\r\n };\r\n Children = {};\r\n };\r\n {\r\n ID = 4;\r\n Type = \"Part\";\r\n Properties = {\r\n Size = Vector3.new(2,1,1);\r\n Transparency = 1;\r\n Name = \"Floor\";\r\n CanCollide = false;\r\n BottomSurface = Enum.SurfaceType.Smooth;\r\n CFrame = CFrame.new(24,0.5,-27.5,1,0,0,0,1,0,0,0,1);\r\n Position = Vector3.new(24,0.5,-27.5);\r\n TopSurface = Enum.SurfaceType.Smooth;\r\n };\r\n Children = {};\r\n };\r\n };\r\n };\r\n\r\n local function Scan(item, parent)\r\n local obj = Instance.new(item.Type)\r\n if (item.ID) then\r\n local awaiting = awaitRef[item.ID]\r\n if (awaiting) then\r\n awaiting[1][awaiting[2]] = obj\r\n awaitRef[item.ID] = nil\r\n else\r\n partsWithId[item.ID] = obj\r\n end\r\n end\r\n for p,v in pairs(item.Properties) do\r\n if (type(v) == \"string\") then\r\n local id = tonumber(v:match(\"^_R:(%w+)_$\"))\r\n if (id) then\r\n if (partsWithId[id]) then\r\n v = partsWithId[id]\r\n else\r\n awaitRef[id] = {obj, p}\r\n v = nil\r\n end\r\n end\r\n end\r\n obj[p] = v\r\n end\r\n for _,c in pairs(item.Children) do\r\n Scan(c, obj)\r\n end\r\n obj.Parent = parent\r\n return obj\r\n end\r\n\r\n script = Scan(root, nil)\r\n _G.initObjects = script\r\nend\r\n\r\nlocal SPHERE = script:WaitForChild(\"Sphere\")\r\nlocal FLOOR = script:WaitForChild(\"Floor\")\r\nlocal VFORCE = script:WaitForChild(\"VectorForce\")\r\nlocal BGYRO = script:WaitForChild(\"BodyGyro\")\r\n\r\nlocal function initObjects(self)\r\n\tlocal hrp = self.HRP\r\n\tlocal humanoid = self.Humanoid\r\n\t\r\n\tlocal sphere = SPHERE:Clone()\r\n\tsphere.Parent = self.Character\r\n\t\r\n\tlocal floor = FLOOR:Clone()\r\n\tfloor.Parent = self.Character\r\n\t\r\n\tlocal isR15 = (humanoid.RigType == Enum.HumanoidRigType.R15)\r\n\tlocal height = isR15 and (humanoid.HipHeight + 0.05) or 2\r\n\t\r\n\tlocal weld = Instance.new(\"Weld\")\r\n\tweld.C0 = CFrame.new(0, -height, 0.1)\r\n\tweld.Part0 = hrp\r\n\tweld.Part1 = sphere\r\n\tweld.Parent = sphere\r\n\t\r\n\tlocal weld2 = Instance.new(\"Weld\")\r\n\tweld2.C0 = CFrame.new(0, -(height + 1.5), 0)\r\n\tweld2.Part0 = hrp\r\n\tweld2.Part1 = floor\r\n\tweld2.Parent = floor\r\n\t\r\n\tlocal gyro = BGYRO:Clone()\r\n\tgyro.CFrame = hrp.CFrame\r\n\tgyro.Parent = hrp\r\n\t\r\n\tlocal vForce = VFORCE:Clone()\r\n\tvForce.Attachment0 = isR15 and hrp:WaitForChild(\"RootRigAttachment\") or hrp:WaitForChild(\"RootAttachment\")\r\n\tvForce.Parent = hrp\r\n\t\r\n\treturn sphere, gyro, vForce, floor\r\nend\r\n\r\nreturn initObjects","Version":"3","StateTracker":"local EPSILON = 0.1\r\n\r\nlocal SPEED = {\r\n\t[\"onRunning\"] = true,\r\n\t[\"onClimbing\"] = true \r\n}\r\n\r\nlocal INAIR = {\r\n\t[\"onFreeFall\"] = true,\r\n\t[\"onJumping\"] = true\r\n}\r\n\r\nlocal STATEMAP = {\r\n\t[\"onRunning\"] = Enum.HumanoidStateType.Running,\r\n\t[\"onJumping\"] = Enum.HumanoidStateType.Jumping,\r\n\t[\"onFreeFall\"] = Enum.HumanoidStateType.Freefall\r\n}\r\n\r\nlocal StateTracker = {}\r\nStateTracker.__index = StateTracker\r\n\r\nfunction StateTracker.new(humanoid)\r\n\tlocal self = setmetatable({}, StateTracker)\r\n\t\r\n\tself.Humanoid = humanoid\r\n\tself.HRP = humanoid.RootPart\r\n\t\r\n\tself.Speed = 0\r\n\tself.State = \"onRunning\"\r\n\tself.Jumped = false\r\n\tself.JumpTick = tick()\r\n\t\r\n\t--self.SoundState = soundState\r\n\t\r\n\tself._ChangedEvent = Instance.new(\"BindableEvent\")\r\n\tself.Changed = self._ChangedEvent.Event\r\n\t\r\n\treturn self\r\nend\r\n\r\nfunction StateTracker:Destroy()\r\n\tself._ChangedEvent:Destroy()\r\nend\r\n\r\nfunction StateTracker:RequestedJump()\r\n\tself.Jumped = true\r\n\tself.JumpTick = tick()\r\nend\r\n\r\nfunction StateTracker:OnStep(gravityUp, grounded, isMoving)\r\n\tlocal cVelocity = self.HRP.Velocity\r\n\tlocal gVelocity = cVelocity:Dot(gravityUp)\r\n\t\r\n\tlocal oldState, oldSpeed = self.State, self.Speed\r\n\t\r\n\tlocal newState\r\n\tlocal newSpeed = cVelocity.Magnitude\r\n\r\n\tif (not grounded) then\r\n\t\tif (gVelocity > 0) then\r\n\t\t\tif (self.Jumped) then\r\n\t\t\t\tnewState = \"onJumping\"\r\n\t\t\telse\r\n\t\t\t\tnewState = \"onFreeFall\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tif (self.Jumped) then\r\n\t\t\t\tself.Jumped = false\r\n\t\t\tend\r\n\t\t\tnewState = \"onFreeFall\"\r\n\t\tend\r\n\telse\r\n\t\tif (self.Jumped and tick() - self.JumpTick > 0.1) then\r\n\t\t\tself.Jumped = false\r\n\t\tend\r\n\t\tnewSpeed = (cVelocity - gVelocity*gravityUp).Magnitude\r\n\t\tnewState = \"onRunning\"\r\n\tend\r\n\t\r\n\tnewSpeed = isMoving and newSpeed or 0\r\n\t\r\n\tif (oldState ~= newState or (SPEED[newState] and math.abs(oldSpeed - newSpeed) > EPSILON)) then\r\n\t\tself.State = newState\r\n\t\tself.Speed = newSpeed\r\n\t\t--self.SoundState:Fire(STATEMAP[newState])\r\n\t\tself.Humanoid:ChangeState(STATEMAP[newState])\r\n\t\tself._ChangedEvent:Fire(self.State, self.Speed)\r\n\tend\r\nend\r\n\r\nreturn StateTracker"}
Editor Settings
Theme
Key bindings
Full width
Lines