Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why will this tool not play the animation?

Asked by
chafava -113
5 years ago

I want an animation to play if I have equipped it, can you fix this script?

local Tool = script.Parent

Tool.Equipped:Connect(function(mouse, player)
    print("A tool was equipped")
    game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
end)
0
Make sure your animation priority is set to action for it to work. If you set it to another priority, it may take longer for the animation to work. Plus make sure to loop your animation, or freeze it if that is what you are going for with the "Equipped" event. Alphexus 498 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

You need to load the Animation id instead of the animation instance itself.

For example:

local Tool = script.Parent

Tool.Equipped:Connect(function(mouse, player)
    print("A tool was equipped")
    local animationId = script.Parent.Animation.AnimationId


    game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animationId)
end)
Ad

Answer this question