So, I made an animation. I made sure it's working and functioning correctly using a keybind script, which it was. So then I used the touched: Event. Everything was functioning fine. But then I realized the animation just kept firing, rendering it completely useless. I used if statements, else if statements, debounce, everything I could. it just doesn't work. Please help me.
local Anim = script.Parent.Transfur
local debounce = false
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
script.Parent.CanCollide = false
hit.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
debounce = true
local AnimTrack = hit.Parent.Humanoid:LoadAnimation(Anim)
AnimTrack.Looped = false
AnimTrack:Play()
if AnimTrack.IsPlaying == false then
AnimTrack:Play()
end
wait(4)
AnimTrack:Stop()
script.Parent.CanCollide = true
end
end)
I just don't know why it's doing this. https://gyazo.com/aa537c3eee066db37453edc0f279c34b
