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

How to add a cool-down to this script? - I'm really new to this

Hey guys, I'm REALLY new to scripting so this might be really easy for all you professionals out there, aha.

But, do you know how to add a cool-down to this simple script? It'd be really appreciated. <3

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()

plr.Character.Humanoid.WalkSpeed = 25 -- your power up

plr.Character.Humanoid.JumpPower = 100 -- your power up

wait(5) -- after 5 sec back to V

plr.Character.Humanoid.WalkSpeed = 16 -- back to normal

plr.Character.Humanoid.JumpPower = 50 -- back to normal

end)

5 comments

0

use a bool variable

0

Use a Debounce

0

use debounce its much easier. just search it up. loads of tutorials on it.

0

hmm after the end (or before) add a wait()

1 answer

Here is the original script:

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()

plr.Character.Humanoid.WalkSpeed = 25 -- your power up

plr.Character.Humanoid.JumpPower = 100 -- your power up

wait(5) -- after 5 sec back to V

plr.Character.Humanoid.WalkSpeed = 16 -- back to normal

plr.Character.Humanoid.JumpPower = 50 -- back to normal

end)

Try using this script:

Debounce = true

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
	if Debounce then
Debounce = false


plr.Character.Humanoid.WalkSpeed = 25 -- your power up

plr.Character.Humanoid.JumpPower = 100 -- your power up

wait(5) -- after 5 sec back to V

plr.Character.Humanoid.WalkSpeed = 16 -- back to normal

plr.Character.Humanoid.JumpPower = 50 -- back to normal
		Debounce = true
	end
end)

^ Hope that helps! :D

2 comments

0

Didn't work. Thanks for trying though! If the script I sent is incorrect, please feel free to change it.

0

hover your mouse over the code, click "view source" shown as an icon as a page with a <>, copy the code from that window, it probably gave an error because 1. copying straight from the page copies the numbers on the right (which is not good), 2. you need to press view all 21 lines, 3. what is script.Parent?

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