There seems to be some delay before the animations (startAnim, chargeAnim, and endAnim) play, and I need it to play almost immediately or else another script won’t work properly. It seems to happen less on chargeAnim and startAnim. While it’s delaying, the animation tries to go back to the default animation. The delay sometimes happens and sometimes doesn’t, there’s a video with the delay happening below:
local script in the tool the player is holding:
local tool = script.Parent
game.Players.LocalPlayer.CharacterAdded:wait()
local char = game.Players.LocalPlayer.Character
local human = char.Humanoid
local anims = char.Animations
local startAnim = human:LoadAnimation(anims.axeBegin)
local chargeAnim = human:LoadAnimation(anims.axeCharge)
local endAnim = human:LoadAnimation(anims.axeFinish)
local playing = false
local activated = false
local function restoreChar()
startAnim:Stop()
chargeAnim:Stop()
endAnim:Stop()
end
tool.Activated:Connect(function()
if playing == false then
playing = true
activated = true
startAnim:Play()
startAnim.Stopped:wait()
chargeAnim:Play()
local charge = 0
while wait(0.05) do
charge = charge+0.05
--if charge = multiple of 4
if math.floor(charge/4)*4 == charge then
chargeAnim:Play()
end
if activated == false then
if charge < 1 then
restoreChar()
playing = false
else
chargeAnim:Stop()
endAnim:Play()
endAnim.Stopped:wait()
restoreChar()
playing = false
break
end
end
end
end
end)
tool.Deactivated:Connect(function()
activated = false
end)