I want to play an animation, affecting the arms of a player’s rig, when they click while using a tool.
The issue here is that, the first time the animation plays, the fade doesn’t work, and the animation goes to the first frame and doesn’t stop until the player clicks again, successfully doing the animation.
Every time a player clicks the tool after the first time, the animation works perfectly.
I have tried waiting for the existence of necessary objects, but couldn’t think of a solution since there are no errors. I either didn’t know what to look for on the developer hub, or this is a new issue entirely.
robloxapp-20210208-2249132.wmv (1.0 MB)
As you can see here, the first time I click the tool, it does the bug.
Here is the code responsible for the animation playing:
local humanoid = player.Character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator") -- animation code for the crushing of the orb
local crushAnimation = Instance.new("Animation")
crushAnimation.AnimationId = "rbxassetid://6365272478"
local crushAnimationTrack = animator:LoadAnimation(crushAnimation)
crushAnimationTrack:Play(0.25) -- fade so the animation is as smooth as needed
crushAnimationTrack:AdjustSpeed(crushAnimationTrack.Length / 1.25) -- play for only needed time