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

How can i put a 5 second cooldown on my roblox sliding script????

Asked by 2 years ago

**So im making a sliding script but i want to stop players from spamming the sliding option

i'd like to make the player wait 5 seconds before they can slide again**

01    local UIS = game:GetService("UserInputService")
02    local character = script.Parent
03    local humanoid = character:WaitForChild("Humanoid")
04    local slideAnim = Instance.new("Animation")
05    slideAnim.AnimationId = "rbxassetid://9618771941"
06 
07 
08    local canslide = false
09    local keybind = Enum.KeyCode.C
10 
11 
12    local topspeed = 25
13    character.Humanoid.Running:Connect(function(speed)
14    if speed > topspeed then
15        canslide = true
View all 55 lines...

2 answers

Log in to vote
0
Answered by 2 years ago

Your script should use debounce. Here is an example - try implementing this into your script.

01local Debounce = false
02 
03function Example()
04    if Debounce == true then return end
05    print("Hello there")
06    Debounce = true
07 
08    wait(1)
09 
10    Debounce = false
11end

If a function is fired while Debounce = true, then the function will immediately end before it can do anything.

0
wait has been superseded by task.wait Ziffixture 6913 — 2y
0
Thanks but where exaclty should i put this? 123marooxd123 13 — 2y
0
could you explain please? what kind of function do i put and where do i put the script? 123marooxd123 13 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

should it be like this? explain please since im new to scripting so i dont understand

0101      local UIS = game:GetService("UserInputService")
0202      local character = script.Parent
0303      local humanoid = character:WaitForChild("Humanoid")
0404      local slideAnim = Instance.new("Animation")
0505      slideAnim.AnimationId = "rbxassetid://9618771941"
0606     
07 
08           local debounce = false
0907   function example()
10        if debounce == true then return end
11        print ("hello")
12        debounce = true
13 
14        wait(5)
15        debounce = false
View all 65 lines...

Answer this question