Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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)

0
use a bool variable DeceptiveCaster 3761 — 5y
0
Use a Debounce DragRacer31 7 — 5y
0
use debounce its much easier. just search it up. loads of tutorials on it. tonyv537 95 — 5y
0
hmm after the end (or before) add a wait() AnotherPerson_999 28 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

0
Didn't work. Thanks for trying though! If the script I sent is incorrect, please feel free to change it. TheObviousNinja 19 — 5y
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? fanofpixels 718 — 5y
Ad

Answer this question