Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my animation not seem to work the first time I play it?

When I click with a tool it's supposed to play an animation which it does, but it only works AFTER the first click (so I have to click twice before the animation actually plays).

local animation = Instance.new("Animation", character)
animation.AnimationId = "rbxassetid://04453025778"
local playAnimation = character:FindFirstChild("Humanoid"):LoadAnimation(animation)
playAnimation:Play()
wait(playAnimation.Length)

*assume that character is already initialized

1 answer

✓ Accepted answer

This is likely because your client needs to load the animation first before it can play it. A lot of times it will not play the animation, or will only play part of it the first time you play it because the client is still loading it.

To avoid this issue you need to Preload the animation using this... https://developer.roblox.com/en-us/api-reference/function/ContentProvider/PreloadAsync

1 comment

1

Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.