How do i cancel animation when using "wait()"?

So pretty straight forward,

I’m working on a gun system and stuff,

So I made a Equipped function where it would do this:

	EquipAnim:Play()
	wait(0.71)
	Tool.EquipEvent:FireServer() --Does it's job to do a blowback and sounds.
	wait(1.38)
	IdleAnim:Play()

However, if u unequip the tool before it does “IdleAnim:Play()” The player will be stuck on that idle animation, can somebody help me out and fix this?

I think what you would have to do is hook the animation when it stopped to when the tool is unequipped. Example:

script.Parent.Unequipped:Connect(function()
EquipAnim:Stop()
end)

Yeah but that doesn’t solve the problem, it only stops the EquipAnim, the script will still start playing the idle animation and it will be stuck on it.

And I already have the unEquipped function, it’s just that it won’t stop the idle once unEquipped in under 1.38 seconds.

What kind of animation priority are the animations? That can effect how everything works.

The track is on Action, as I already said “once unEquipped in under 1.38 seconds, the idle animation won’t stop even with the unEquipped function”

Why don’t you have a variable named “equipped”. When they equip the tool set it to true, when they unequal it to false. Then check if it is true before playing the idle animation.

1 Like

Oh yeah, smart one, i’ll try it out.

1 Like

Sir, I legit spent 2 hours figuring this out, and you legit made me seem like an absolute idiot, I don’t know why but I always think hard on easy things, thanks it worked.

No problem! Yeah I always overthink it too, glad it worked :slight_smile: !

1 Like