Hi. For a while I have been having trouble with getting animations to play. I have the following LocalScript in StarterPack:
local hum = game.Players.LocalPlayer.Character.Humanoid local ani = Instance.new("Animation") ani.AnimationId = "http://www.roblox.com/asset/?id=180436148" local anit = hum:LoadAnimation(game.Players.LocalPlayer.Character.Animate.climb.ClimbAnim) anit.KeyframeReached:connect(function(keyframeName) print(keyframeName) end) while wait(1) do print("Run") anit:Play() end
In the output I only get "Run" once about each second. No animation plays from this.
EDIT: It appears that the animation plays, when using a dedicated client with server. Why is this?
For your anit variable, you're not loading your actual animation and this is why your animation doesn't play. You need to do hum:LoadAnimation(ani)
so that the animation loads and then you can play it using the Play method.
Your final script should look something like this:
local player = game.Players.LocalPlayer --Gets the local player local char = player.Character or player.CharacterAdded:wait() --If the character is available, it uses the character property, otherwise it waits for the character then returns it. local hum = char:WaitForChild("Humanoid") --Waits for the character's humanoid. local ani = Instance.new("Animation") ani.AnimationId = "http://www.roblox.com/asset/?id=180436148" local anit = hum:LoadAnimation(ani) --Load the actual animation. anit.KeyframeReached:connect(function(keyframeName) print(keyframeName) end) while wait(1) do print("Run") anit:Play() end
I hope my answer helped you. If it did, be sure to accept it.
More information on this subject here.