Animation.Stopped:Wait() Isn't Working?

local tool = script.Parent
local plr = tool.Parent.Parent
local char = plr.Character
local humanoid = char:WaitForChild("Humanoid")
local sound = tool.Handle.Sound
local db = false
local idle = humanoid:WaitForChild("Animator"):LoadAnimation(script.Idle)
local activate = humanoid:WaitForChild("Animator"):LoadAnimation(script.Activate)
local idle2 = humanoid:WaitForChild("Animator"):LoadAnimation(script.ActivateIdle)
local unequip = humanoid:WaitForChild("Animator"):LoadAnimation(script.Unequip)

tool.Equipped:Connect(function()
	idle:Play()
end)

tool.Activated:Connect(function()
	if db == false then
		print("sounding")
		db = true
		idle:Stop()
		print(idle.IsPlaying)
		print("idle stopped")
		activate:Play()
		print("activate playing")
		activate.Stopped:Wait()
		print("activate finished")
		sound:Play()
		print("sound playing")
		idle2:Play()
		sound.Stopped:Wait()
		print("finished")
		idle2:Stop()
		unequip:Play()
		unequip.Stopped:Wait()
		idle:Play()
		db = false
	end
end)

tool.Unequipped:Connect(function()
	unequip:Play()
	idle:Stop()
end)

For some reason, when I activate the script it only gets as far as Activate.Stopped:Wait() and does not go past that. I can’t think of whats causing the problem and im really stuck.

1 Like

:Wait() Yields until the function fires so if the animation is looped, it will never unyield

1 Like

The animation shouldnt be looped, even so ill reupload it to double check.

1 Like

Strangely it seem that all the animations are the idle animations. But reuploading fixed it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.