How can i put a 5 second cooldown on my roblox sliding script????
**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" ) |
08 | local canslide = false |
09 | local keybind = Enum.KeyCode.C |
13 | character.Humanoid.Running:Connect( function (speed) |
14 | if speed > topspeed then |
16 | else if speed < topspeed then |
22 | humanoid:GetPropertyChangedSignal( "FloorMaterial" ):Connect( function () |
23 | if humanoid.FloorMaterial = = Enum.Material.Air then |
25 | else if humanoid.FloorMaterial ~ = Enum.Material.Air then |
31 | UIS.InputBegan:Connect( function (input,gameprocessed) |
32 | if gameprocessed then return end |
33 | if not canslide then return end |
34 | if input.KeyCode = = keybind then |
37 | local playAnim = character.Humanoid:LoadAnimation(slideAnim) |
41 | local slide = Instance.new( "BodyVelocity" ) |
42 | slide.MaxForce = Vector 3. new( 1 , 0 , 1 ) * 30000 |
43 | slide.Velocity = character.HumanoidRootPart.CFrame.lookVector * 100 |
44 | slide.Parent = character.HumanoidRootPart |