I have this code that increases the player's walkspeed to 70 when they touch a part. I want this code to give the player a speed boost for 7 seconds when they touch it, but I want them to be able to renew that speed boost after 1.5 seconds.
Basically, if they touch the part after 1.5 seconds has gone by, the code restarts from the beginning and they have 7 seconds of speed boost again. How can I do that?
local part = script.Parent
part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Sound = game.Workspace.Sounds.SpeedPowerPadAudio1:Clone()
local humanoid = hit.Parent:findFirstChild("Humanoid")
local Red = script.Parent.Parent.Yellowtored
Sound.Parent = Player.PlayerGui
Sound:Play()
part.CanTouch = false
humanoid.WalkSpeed = 70
Red.BrickColor = BrickColor.Red()
wait(1.5)
Red.BrickColor = BrickColor.new("Deep orange")
wait(5.5)
part.CanTouch = true
humanoid.WalkSpeed = 25
end
end)

2 comments
This doesn't do anything
maybe now it will work