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

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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
Thank you so much! Brandon1881 721 — 5y
Ad

Answer this question