**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**
local UIS = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://9618771941"
local canslide = false
local keybind = Enum.KeyCode.C
local topspeed = 25
character.Humanoid.Running:Connect(function(speed)
if speed > topspeed then
canslide = true
else if speed < topspeed then
canslide = false
end
end
end)
humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
if humanoid.FloorMaterial == Enum.Material.Air then
canslide = false
else if humanoid.FloorMaterial ~= Enum.Material.Air then
canslide = true
end
end
UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end
if input.KeyCode == keybind then
canslide = false
local playAnim = character.Humanoid:LoadAnimation(slideAnim)
playAnim:Play()
local slide = Instance.new("BodyVelocity")
slide.MaxForce = Vector3.new(1,0,1) * 30000
slide.Velocity = character.HumanoidRootPart.CFrame.lookVector * 100
slide.Parent = character.HumanoidRootPart
for count = 1, 8 do
wait(0.15)
slide.Velocity*= 0.7
end
playAnim:Stop()
slide:Destroy()
canslide = true
end
end)
end)

3 comments
wait has been superseded by task.wait
Thanks but where exaclty should i put this?
could you explain please? what kind of function do i put and where do i put the script?