Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I add a cooldown to this Animation?

The Local Script:

script.Parent.Activated:Connect(function()
	script.Parent.RemoteEvent:FireServer()
	
end)

The Server Script:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(Player)
			
		local Animation = script.Parent.Animation
		local animationTrack = Player.Character.Humanoid:LoadAnimation(Animation)
		animationTrack:Play()
		
		local Tool = script.Parent
		Tool.GripForward = Vector3.new(0.989, -0.151, -0.009)
		Tool.GripPos = Vector3.new(-0.566, -1.024, 0.181)
		Tool.GripRight = Vector3.new(0.151, 0.987, 0.059)
		Tool.GripUp = Vector3.new(0, 0.06, -0.998)
		wait(1.2)
		
		animationTrack.Stopped:Connect(function()
			Tool.GripForward = Vector3.new(0.989, 0, -0.151)
			Tool.GripPos = Vector3.new(-0.566, -0.588, 0)
			Tool.GripRight = Vector3.new(0.151, 0, 0.989)
			Tool.GripUp = Vector3.new(0, 1, 0)
		
	end)
end)

I wanted it to have a 2-second cooldown but I have tried debounce and other ways from YouTube and I am lost how to add a cooldown to this. Thanks for the help.

2 comments

0

animations should be loaded from the client

0

Not exactly, Animations can be loaded from both. You could have a funny game where you make everyone do an animation dance if somebody clicks a TextButton. So yeah, you can load it both ways, but Client is more common.

2 answers

✓ Accepted answer

adding a wait after firing the remote

2 comments

0

This should be a comment, if you're answering a question, add more detail. Only answer questions for more complex scripts, like I said. What you said could be said easily with a quick post of a comment. But you're new so I don't care xD. Just be more aware.

0

im sorry ;(

do wait(your time to want to wait till the script under is activated)

This discussion is preserved as it was. New answers, comments, and votes are closed.