How do I make this code restart from the beginning if a part is touched after 1.5 seconds?
Asked by
2 years ago Edited 2 years ago
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?
01 | local part = script.Parent |
03 | part.Touched:Connect( function (hit) |
04 | local humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
06 | local Player = game.Players:GetPlayerFromCharacter(hit.Parent) |
07 | local Sound = game.Workspace.Sounds.SpeedPowerPadAudio 1 :Clone() |
08 | local humanoid = hit.Parent:findFirstChild( "Humanoid" ) |
09 | local Red = script.Parent.Parent.Yellowtored |
10 | Sound.Parent = Player.PlayerGui |
15 | humanoid.WalkSpeed = 70 |
16 | Red.BrickColor = BrickColor.Red() |
18 | Red.BrickColor = BrickColor.new( "Deep orange" ) |
21 | humanoid.WalkSpeed = 25 |