Help with an animation script

Animations can be overlapped. I’ve tried multiple things to stop it. Can anyone help?

local InUse = false
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if InUse == false then
		InUse = true
		char = plr.Character
		anim = char.Humanoid:LoadAnimation(script.Parent.Animation)
		anim:Play()
		char.HumanoidRootPart.Anchored = true
		char.HumanoidRootPart.CFrame = game.Workspace.SpiderPos.CFrame
	else
		InUse = false
		anim:Stop()
		char.HumanoidRootPart.Anchored = false
	end
	wait(0.3)
	char.HumanoidRootPart.Changed:Connect(function()
		if not char.HumanoidRootPart.CFrame == game.Workspace.SpiderPos.CFrame then
			InUse = false
			anim:Stop()
			char.HumanoidRootPart.Anchored = false
		end
	end)
end)
1 Like