Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Installing..")
- wait(0.25)
- script.Name = "Animate"
- local plr = game.Players.LocalPlayer
- local C = plr.Character
- wait(0.5)
- script.Parent = C
- local animate = C:FindFirstChild("Animate")
- wait(0.25)
- model=Instance.new("Model",script)cheer=Instance.new("StringValue")
- cheeranim=Instance.new("Animation")climb=Instance.new("StringValue")
- climbanim=Instance.new("Animation")dance=Instance.new("StringValue")
- animation1=Instance.new("Animation")weight=Instance.new("NumberValue")
- animation2=Instance.new("Animation")weight_2=Instance.new("NumberValue")
- animation3=Instance.new("Animation")weight_3=Instance.new("NumberValue")
- dance2=Instance.new("StringValue")animation1_2=Instance.new("Animation")
- weight_4=Instance.new("NumberValue")animation2_2=Instance.new("Animation")
- weight_5=Instance.new("NumberValue")animation3_2=Instance.new("Animation")
- weight_6=Instance.new("NumberValue")dance3=Instance.new("StringValue")
- animation1_3=Instance.new("Animation")weight_7=Instance.new("NumberValue")
- animation2_3=Instance.new("Animation")weight_8=Instance.new("NumberValue")
- animation3_3=Instance.new("Animation")weight_9=Instance.new("NumberValue")
- fall=Instance.new("StringValue")fallanim=Instance.new("Animation")
- idle=Instance.new("StringValue")animation1_4=Instance.new("Animation")
- weight_10=Instance.new("NumberValue")animation2_4=Instance.new("Animation")
- weight_11=Instance.new("NumberValue")jump=Instance.new("StringValue")
- jumpanim=Instance.new("Animation")laugh=Instance.new("StringValue")
- laughanim=Instance.new("Animation")point=Instance.new("StringValue")
- pointanim=Instance.new("Animation")pose=Instance.new("StringValue")
- mocappose=Instance.new("Animation")weight_12=Instance.new("NumberValue")
- run=Instance.new("StringValue")runanim=Instance.new("Animation")
- sit=Instance.new("StringValue")sitanim=Instance.new("Animation")
- swim=Instance.new("StringValue")swim_2=Instance.new("Animation")
- swimidle=Instance.new("StringValue")swimidle_2=Instance.new("Animation")
- toollunge=Instance.new("StringValue")toollungeanim=Instance.new("Animation")
- toolnone=Instance.new("StringValue")toolnoneanim=Instance.new("Animation")
- toolslash=Instance.new("StringValue")toolslashanim=Instance.new("Animation")
- walk=Instance.new("StringValue")walkanim=Instance.new("Animation")
- wave=Instance.new("StringValue")waveanim=Instance.new("Animation")cheer.Name="cheer"
- cheer.Parent=model;cheeranim.Name="CheerAnim"
- cheeranim.AnimationId="http://www.roblox.com/asset/?id=507770677"cheeranim.Parent=cheer;climb.Name="climb"climb.Parent=model
- climbanim.Name="ClimbAnim"climbanim.AnimationId="rbxassetid://913362637"
- climbanim.Parent=climb;dance.Name="dance"dance.Parent=model;animation1.Name="Animation1"
- animation1.AnimationId="http://www.roblox.com/asset/?id=507771019"animation1.Parent=dance;weight.Value=10;weight.Name="Weight"
- weight.Parent=animation1;animation2.Name="Animation2"
- animation2.AnimationId="http://www.roblox.com/asset/?id=507771955"animation2.Parent=dance;weight_2.Value=10;weight_2.Name="Weight"
- weight_2.Parent=animation2;animation3.Name="Animation3"
- animation3.AnimationId="http://www.roblox.com/asset/?id=507772104"animation3.Parent=dance;weight_3.Value=10;weight_3.Name="Weight"
- weight_3.Parent=animation3;dance2.Name="dance2"dance2.Parent=model
- animation1_2.Name="Animation1"animation1_2.AnimationId="http://www.roblox.com/asset/?id=507776043"
- animation1_2.Parent=dance2;weight_4.Value=10;weight_4.Name="Weight"
- weight_4.Parent=animation1_2;animation2_2.Name="Animation2"
- animation2_2.AnimationId="http://www.roblox.com/asset/?id=507776720"animation2_2.Parent=dance2;weight_5.Value=10
- weight_5.Name="Weight"weight_5.Parent=animation2_2;animation3_2.Name="Animation3"
- animation3_2.AnimationId="http://www.roblox.com/asset/?id=507776879"animation3_2.Parent=dance2;weight_6.Value=10
- weight_6.Name="Weight"weight_6.Parent=animation3_2;dance3.Name="dance3"
- dance3.Parent=model;animation1_3.Name="Animation1"
- animation1_3.AnimationId="http://www.roblox.com/asset/?id=507777268"animation1_3.Parent=dance3;weight_7.Value=10
- weight_7.Name="Weight"weight_7.Parent=animation1_3;animation2_3.Name="Animation2"
- animation2_3.AnimationId="http://www.roblox.com/asset/?id=507777451"animation2_3.Parent=dance3;weight_8.Value=10
- weight_8.Name="Weight"weight_8.Parent=animation2_3;animation3_3.Name="Animation3"
- animation3_3.AnimationId="http://www.roblox.com/asset/?id=507777623"animation3_3.Parent=dance3;weight_9.Value=10
- weight_9.Name="Weight"weight_9.Parent=animation3_3;fall.Name="fall"fall.Parent=model
- fallanim.Name="FallAnim"fallanim.AnimationId="rbxassetid://913365531"fallanim.Parent=fall
- idle.Name="idle"idle.Parent=model;animation1_4.Name="Animation1"
- animation1_4.AnimationId="rbxassetid://913367814"animation1_4.Parent=idle;weight_10.Value=9
- weight_10.Name="Weight"weight_10.Parent=animation1_4;animation2_4.Name="Animation2"
- animation2_4.AnimationId="rbxassetid://913373430"animation2_4.Parent=idle;weight_11.Value=1
- weight_11.Name="Weight"weight_11.Parent=animation2_4;jump.Name="jump"jump.Parent=model
- jumpanim.Name="JumpAnim"jumpanim.AnimationId="rbxassetid://913370268"jumpanim.Parent=jump
- laugh.Name="laugh"laugh.Parent=model;laughanim.Name="LaughAnim"
- laughanim.AnimationId="http://www.roblox.com/asset/?id=507770818"laughanim.Parent=laugh;point.Name="point"point.Parent=model
- pointanim.Name="PointAnim"pointanim.AnimationId="http://www.roblox.com/asset/?id=507770453"
- pointanim.Parent=point;pose.Name="pose"pose.Parent=model;mocappose.Name="MocapPose"
- mocappose.AnimationId="rbxassetid://0"mocappose.Parent=pose;weight_12.Name="Weight"
- weight_12.Parent=mocappose;run.Name="run"run.Parent=model;runanim.Name="RunAnim"
- runanim.AnimationId="rbxassetid://913376220"runanim.Parent=run;sit.Name="sit"sit.Parent=model
- sitanim.Name="SitAnim"sitanim.AnimationId="http://www.roblox.com/asset/?id=507768133"
- sitanim.Parent=sit;swim.Name="swim"swim.Parent=model;swim_2.Name="Swim"
- swim_2.AnimationId="rbxassetid://913384386"swim_2.Parent=swim;swimidle.Name="swimidle"swimidle.Parent=model
- swimidle_2.Name="SwimIdle"swimidle_2.AnimationId="rbxassetid://913389285"
- swimidle_2.Parent=swimidle;toollunge.Name="toollunge"toollunge.Parent=model
- toollungeanim.Name="ToolLungeAnim"toollungeanim.AnimationId="http://www.roblox.com/asset/?id=522638767"
- toollungeanim.Parent=toollunge;toolnone.Name="toolnone"toolnone.Parent=model
- toolnoneanim.Name="ToolNoneAnim"toolnoneanim.AnimationId="http://www.roblox.com/asset/?id=507768375"
- toolnoneanim.Parent=toolnone;toolslash.Name="toolslash"toolslash.Parent=model
- toolslashanim.Name="ToolSlashAnim"toolslashanim.AnimationId="http://www.roblox.com/asset/?id=522635514"
- toolslashanim.Parent=toolslash;walk.Name="walk"walk.Parent=model;walkanim.Name="WalkAnim"
- walkanim.AnimationId="rbxassetid://913402848"walkanim.Parent=walk;wave.Name="wave"wave.Parent=model
- waveanim.Name="WaveAnim"waveanim.AnimationId="http://www.roblox.com/asset/?id=507770239"
- waveanim.Parent=wave
- function Ungroup(this)--n
- for _,e in pairs(this:children()) do--n
- e.Parent = this.Parent;--n
- end--n
- end--n
- --n
- wait(0.25)
- if animate then
- animate:destroy()
- end
- Ungroup(script.Model)--y
- wait(0.1)script.Model:destroy()
- print([[Completed MoCap animations,
- Animations by ROBLOX, Script Injecter by SlayKillerX66]])
- local Character = C
- local Humanoid = Character:WaitForChild("Humanoid")
- local pose = "Standing"
- local currentAnim = ""
- local currentAnimInstance = nil
- local currentAnimTrack = nil
- local currentAnimKeyframeHandler = nil
- local currentAnimSpeed = 1.0
- local runAnimTrack = nil
- local runAnimKeyframeHandler = nil
- local animTable = {}
- local animNames = {
- idle = {
- { id = "http://www.roblox.com/asset/?id=507766666", weight = 1 },
- { id = "http://www.roblox.com/asset/?id=507766951", weight = 1 },
- { id = "http://www.roblox.com/asset/?id=507766388", weight = 9 }
- },
- walk = {
- { id = "http://www.roblox.com/asset/?id=507777826", weight = 10 }
- },
- run = {
- { id = "http://www.roblox.com/asset/?id=507767714", weight = 10 }
- },
- swim = {
- { id = "http://www.roblox.com/asset/?id=507784897", weight = 10 }
- },
- swimidle = {
- { id = "http://www.roblox.com/asset/?id=507785072", weight = 10 }
- },
- jump = {
- { id = "http://www.roblox.com/asset/?id=507765000", weight = 10 }
- },
- fall = {
- { id = "http://www.roblox.com/asset/?id=507767968", weight = 10 }
- },
- climb = {
- { id = "http://www.roblox.com/asset/?id=507765644", weight = 10 }
- },
- sit = {
- { id = "http://www.roblox.com/asset/?id=507768133", weight = 10 }
- },
- toolnone = {
- { id = "http://www.roblox.com/asset/?id=507768375", weight = 10 }
- },
- toolslash = {
- { id = "http://www.roblox.com/asset/?id=522635514", weight = 10 }
- },
- toollunge = {
- { id = "http://www.roblox.com/asset/?id=522638767", weight = 10 }
- },
- wave = {
- { id = "http://www.roblox.com/asset/?id=507770239", weight = 10 }
- },
- point = {
- { id = "http://www.roblox.com/asset/?id=507770453", weight = 10 }
- },
- dance = {
- { id = "http://www.roblox.com/asset/?id=507771019", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=507771955", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=507772104", weight = 10 }
- },
- dance2 = {
- { id = "http://www.roblox.com/asset/?id=507776043", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=507776720", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=507776879", weight = 10 }
- },
- dance3 = {
- { id = "http://www.roblox.com/asset/?id=507777268", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=507777451", weight = 10 },
- { id = "http://www.roblox.com/asset/?id=507777623", weight = 10 }
- },
- laugh = {
- { id = "http://www.roblox.com/asset/?id=507770818", weight = 10 }
- },
- cheer = {
- { id = "http://www.roblox.com/asset/?id=507770677", weight = 10 }
- },
- }
- -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
- local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}
- local PreloadAnimsUserFlag = false
- local successPreloadAnim, msgPreloadAnim = pcall(function()
- PreloadAnimsUserFlag = UserSettings():IsUserFeatureEnabled("UserPreloadAnimations")
- end)
- if not successPreloadAnim then
- PreloadAnimsUserFlag = false
- end
- math.randomseed(tick())
- function configureAnimationSet(name, fileList)
- if (animTable[name] ~= nil) then
- for _, connection in pairs(animTable[name].connections) do
- connection:disconnect()
- end
- end
- animTable[name] = {}
- animTable[name].count = 0
- animTable[name].totalWeight = 0
- animTable[name].connections = {}
- local allowCustomAnimations = true
- local AllowDisableCustomAnimsUserFlag = false
- local success, msg = pcall(function()
- AllowDisableCustomAnimsUserFlag = UserSettings():IsUserFeatureEnabled("UserAllowDisableCustomAnims2")
- end)
- if (AllowDisableCustomAnimsUserFlag) then
- local success, msg = pcall(function() allowCustomAnimations = game:GetService("StarterPlayer").AllowCustomAnimations end)
- if not success then
- allowCustomAnimations = true
- end
- end
- -- check for config values
- local config = script:FindFirstChild(name)
- if (allowCustomAnimations and config ~= nil) then
- table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
- table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
- local idx = 1
- for _, childPart in pairs(config:GetChildren()) do
- if (childPart:IsA("Animation")) then
- table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
- animTable[name][idx] = {}
- animTable[name][idx].anim = childPart
- local weightObject = childPart:FindFirstChild("Weight")
- if (weightObject == nil) then
- animTable[name][idx].weight = 1
- else
- animTable[name][idx].weight = weightObject.Value
- end
- animTable[name].count = animTable[name].count + 1
- animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
- idx = idx + 1
- end
- end
- end
- -- fallback to defaults
- if (animTable[name].count <= 0) then
- for idx, anim in pairs(fileList) do
- animTable[name][idx] = {}
- animTable[name][idx].anim = Instance.new("Animation")
- animTable[name][idx].anim.Name = name
- animTable[name][idx].anim.AnimationId = anim.id
- animTable[name][idx].weight = anim.weight
- animTable[name].count = animTable[name].count + 1
- animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
- -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
- end
- end
- -- preload anims
- if PreloadAnimsUserFlag then
- for i, animType in pairs(animTable) do
- for idx = 1, animType.count, 1 do
- Humanoid:LoadAnimation(animType[idx].anim)
- end
- end
- end
- end
- -- Setup animation objects
- function scriptChildModified(child)
- local fileList = animNames[child.Name]
- if (fileList ~= nil) then
- configureAnimationSet(child.Name, fileList)
- end
- end
- script.ChildAdded:connect(scriptChildModified)
- script.ChildRemoved:connect(scriptChildModified)
- for name, fileList in pairs(animNames) do
- configureAnimationSet(name, fileList)
- end
- -- ANIMATION
- -- declarations
- local toolAnim = "None"
- local toolAnimTime = 0
- local jumpAnimTime = 0
- local jumpAnimDuration = 0.31
- local toolTransitionTime = 0.1
- local fallTransitionTime = 0.2
- -- functions
- function stopAllAnimations()
- local oldAnim = currentAnim
- -- return to idle if finishing an emote
- if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
- oldAnim = "idle"
- end
- currentAnim = ""
- currentAnimInstance = nil
- if (currentAnimKeyframeHandler ~= nil) then
- currentAnimKeyframeHandler:disconnect()
- end
- if (currentAnimTrack ~= nil) then
- currentAnimTrack:Stop()
- currentAnimTrack:Destroy()
- currentAnimTrack = nil
- end
- -- clean up walk if there is one
- if (runAnimKeyframeHandler ~= nil) then
- runAnimKeyframeHandler:disconnect()
- end
- if (runAnimTrack ~= nil) then
- runAnimTrack:Stop()
- runAnimTrack:Destroy()
- runAnimTrack = nil
- end
- return oldAnim
- end
- function getHeightScale()
- if Humanoid then
- local bodyHeightScale = Humanoid:FindFirstChild("BodyHeightScale")
- if bodyHeightScale and bodyHeightScale:IsA("NumberValue") then
- return bodyHeightScale.Value
- end
- end
- return 1
- end
- local smallButNotZero = 0.0001
- function setRunSpeed(speed)
- if speed < 0.33 then
- currentAnimTrack:AdjustWeight(1.0)
- runAnimTrack:AdjustWeight(smallButNotZero)
- elseif speed < 0.66 then
- local weight = ((speed - 0.33) / 0.33)
- currentAnimTrack:AdjustWeight(1.0 - weight + smallButNotZero)
- runAnimTrack:AdjustWeight(weight + smallButNotZero)
- else
- currentAnimTrack:AdjustWeight(smallButNotZero)
- runAnimTrack:AdjustWeight(1.0)
- end
- local speedScaled = speed * 1.25
- local heightScale = getHeightScale()
- runAnimTrack:AdjustSpeed(speedScaled / heightScale)
- currentAnimTrack:AdjustSpeed(speedScaled / heightScale)
- end
- function setAnimationSpeed(speed)
- if speed ~= currentAnimSpeed then
- currentAnimSpeed = speed
- if currentAnim == "walk" then
- setRunSpeed(speed)
- else
- currentAnimTrack:AdjustSpeed(currentAnimSpeed)
- end
- end
- end
- function keyFrameReachedFunc(frameName)
- if (frameName == "End") then
- if currentAnim == "walk" then
- runAnimTrack.TimePosition = 0.0
- currentAnimTrack.TimePosition = 0.0
- else
- local repeatAnim = currentAnim
- -- return to idle if finishing an emote
- if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
- repeatAnim = "idle"
- end
- local animSpeed = currentAnimSpeed
- playAnimation(repeatAnim, 0.15, Humanoid)
- setAnimationSpeed(animSpeed)
- end
- end
- end
- function rollAnimation(animName)
- local roll = math.random(1, animTable[animName].totalWeight)
- local origRoll = roll
- local idx = 1
- while (roll > animTable[animName][idx].weight) do
- roll = roll - animTable[animName][idx].weight
- idx = idx + 1
- end
- return idx
- end
- function playAnimation(animName, transitionTime, humanoid)
- local idx = rollAnimation(animName)
- local anim = animTable[animName][idx].anim
- -- switch animation
- if (anim ~= currentAnimInstance) then
- if (currentAnimTrack ~= nil) then
- currentAnimTrack:Stop(transitionTime)
- currentAnimTrack:Destroy()
- end
- if (runAnimTrack ~= nil) then
- runAnimTrack:Stop(transitionTime)
- runAnimTrack:Destroy()
- end
- currentAnimSpeed = 1.0
- -- load it to the humanoid; get AnimationTrack
- currentAnimTrack = humanoid:LoadAnimation(anim)
- currentAnimTrack.Priority = Enum.AnimationPriority.Core
- -- play the animation
- currentAnimTrack:Play(transitionTime)
- currentAnim = animName
- currentAnimInstance = anim
- -- set up keyframe name triggers
- if (currentAnimKeyframeHandler ~= nil) then
- currentAnimKeyframeHandler:disconnect()
- end
- currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
- -- check to see if we need to blend a walk/run animation
- if animName == "walk" then
- local runAnimName = "run"
- local runIdx = rollAnimation(runAnimName)
- runAnimTrack = humanoid:LoadAnimation(animTable[runAnimName][runIdx].anim)
- runAnimTrack.Priority = Enum.AnimationPriority.Core
- runAnimTrack:Play(transitionTime)
- if (runAnimKeyframeHandler ~= nil) then
- runAnimKeyframeHandler:disconnect()
- end
- runAnimKeyframeHandler = runAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
- end
- end
- end
- -------------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------------------
- local toolAnimName = ""
- local toolAnimTrack = nil
- local toolAnimInstance = nil
- local currentToolAnimKeyframeHandler = nil
- function toolKeyFrameReachedFunc(frameName)
- if (frameName == "End") then
- playToolAnimation(toolAnimName, 0.0, Humanoid)
- end
- end
- function playToolAnimation(animName, transitionTime, humanoid, priority)
- local idx = rollAnimation(animName)
- local anim = animTable[animName][idx].anim
- if (toolAnimInstance ~= anim) then
- if (toolAnimTrack ~= nil) then
- toolAnimTrack:Stop()
- toolAnimTrack:Destroy()
- transitionTime = 0
- end
- -- load it to the humanoid; get AnimationTrack
- toolAnimTrack = humanoid:LoadAnimation(anim)
- if priority then
- toolAnimTrack.Priority = priority
- end
- -- play the animation
- toolAnimTrack:Play(transitionTime)
- toolAnimName = animName
- toolAnimInstance = anim
- currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
- end
- end
- function stopToolAnimations()
- local oldAnim = toolAnimName
- if (currentToolAnimKeyframeHandler ~= nil) then
- currentToolAnimKeyframeHandler:disconnect()
- end
- toolAnimName = ""
- toolAnimInstance = nil
- if (toolAnimTrack ~= nil) then
- toolAnimTrack:Stop()
- toolAnimTrack:Destroy()
- toolAnimTrack = nil
- end
- return oldAnim
- end
- -------------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------------------
- -- STATE CHANGE HANDLERS
- function onRunning(speed)
- if speed > 0.5 then
- local scale = 16.0
- playAnimation("walk", 0.2, Humanoid)
- setAnimationSpeed(speed / scale)
- pose = "Running"
- else
- if emoteNames[currentAnim] == nil then
- playAnimation("idle", 0.2, Humanoid)
- pose = "Standing"
- end
- end
- end
- function onDied()
- pose = "Dead"
- end
- function onJumping()
- playAnimation("jump", 0.1, Humanoid)
- jumpAnimTime = jumpAnimDuration
- pose = "Jumping"
- end
- function onClimbing(speed)
- local scale = 5.0
- playAnimation("climb", 0.1, Humanoid)
- setAnimationSpeed(speed / scale)
- pose = "Climbing"
- end
- function onGettingUp()
- pose = "GettingUp"
- end
- function onFreeFall()
- if (jumpAnimTime <= 0) then
- playAnimation("fall", fallTransitionTime, Humanoid)
- end
- pose = "FreeFall"
- end
- function onFallingDown()
- pose = "FallingDown"
- end
- function onSeated()
- pose = "Seated"
- end
- function onPlatformStanding()
- pose = "PlatformStanding"
- end
- -------------------------------------------------------------------------------------------
- -------------------------------------------------------------------------------------------
- function onSwimming(speed)
- if speed > 1.00 then
- local scale = 10.0
- playAnimation("swim", 0.4, Humanoid)
- setAnimationSpeed(speed / scale)
- pose = "Swimming"
- else
- playAnimation("swimidle", 0.4, Humanoid)
- pose = "Standing"
- end
- end
- function animateTool()
- if (toolAnim == "None") then
- playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)
- return
- end
- if (toolAnim == "Slash") then
- playToolAnimation("toolslash", 0, Humanoid, Enum.AnimationPriority.Action)
- return
- end
- if (toolAnim == "Lunge") then
- playToolAnimation("toollunge", 0, Humanoid, Enum.AnimationPriority.Action)
- return
- end
- end
- function getToolAnim(tool)
- for _, c in ipairs(tool:GetChildren()) do
- if c.Name == "toolanim" and c.className == "StringValue" then
- return c
- end
- end
- return nil
- end
- local lastTick = 0
- function stepAnimate(currentTime)
- local amplitude = 1
- local frequency = 1
- local deltaTime = currentTime - lastTick
- lastTick = currentTime
- local climbFudge = 0
- local setAngles = false
- if (jumpAnimTime > 0) then
- jumpAnimTime = jumpAnimTime - deltaTime
- end
- if (pose == "FreeFall" and jumpAnimTime <= 0) then
- playAnimation("fall", fallTransitionTime, Humanoid)
- elseif (pose == "Seated") then
- playAnimation("sit", 0.5, Humanoid)
- return
- elseif (pose == "Running") then
- playAnimation("walk", 0.2, Humanoid)
- elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
- stopAllAnimations()
- amplitude = 0.1
- frequency = 1
- setAngles = true
- end
- -- Tool Animation handling
- local tool = Character:FindFirstChildOfClass("Tool")
- local requireHandleCheck = not UserSettings():IsUserFeatureEnabled("UserToolR15Fix")
- if tool and ((requireHandleCheck and tool.RequiresHandle) or tool:FindFirstChild("Handle")) then
- local animStringValueObject = getToolAnim(tool)
- if animStringValueObject then
- toolAnim = animStringValueObject.Value
- -- message recieved, delete StringValue
- animStringValueObject.Parent = nil
- toolAnimTime = currentTime + .3
- end
- if currentTime > toolAnimTime then
- toolAnimTime = 0
- toolAnim = "None"
- end
- animateTool()
- else
- stopToolAnimations()
- toolAnim = "None"
- toolAnimInstance = nil
- toolAnimTime = 0
- end
- end
- -- connect events
- Humanoid.Died:connect(onDied)
- Humanoid.Running:connect(onRunning)
- Humanoid.Jumping:connect(onJumping)
- Humanoid.Climbing:connect(onClimbing)
- Humanoid.GettingUp:connect(onGettingUp)
- Humanoid.FreeFalling:connect(onFreeFall)
- Humanoid.FallingDown:connect(onFallingDown)
- Humanoid.Seated:connect(onSeated)
- Humanoid.PlatformStanding:connect(onPlatformStanding)
- Humanoid.Swimming:connect(onSwimming)
- -- setup emote chat hook
- game:GetService("Players").LocalPlayer.Chatted:connect(function(msg)
- local emote = ""
- if (string.sub(msg, 1, 3) == "/e ") then
- emote = string.sub(msg, 4)
- elseif (string.sub(msg, 1, 7) == "/emote ") then
- emote = string.sub(msg, 8)
- end
- if (pose == "Standing" and emoteNames[emote] ~= nil) then
- playAnimation(emote, 0.1, Humanoid)
- end
- end)
- -- initialize to idle
- playAnimation("idle", 0.1, Humanoid)
- pose = "Standing"
- -- loop to handle timed state transitions and tool animations
- while Character.Parent ~= nil do
- local _, currentGameTime = wait(0.1)
- stepAnimate(currentGameTime)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement