-
What do you want to achieve? I have a speed pickup in my game that I want the player to use one at a time. For example: A player will step over the pickup and they will get a speed increase. No players should be able to use it until it cools down and the player loses their extra speed.
-
What is the issue? While the script works, it can still be used by other players while it’s original user has their extra speed.
-
What solutions have you tried so far? I cannot find anything like this online.
2 Likes
From what I can see, you are not checking the debounce when the part is touched. People can go over and over again as long as there is no checking of the true/false debounce
2 Likes
---------------
local NewWS = 30
local Cooldown = 5
----------------
local dbg = true
local PlayerOldWS = 16
script.Parent.Color = Color3.fromRGB(0,255,0)
script.Parent.Touched:Connect(function(t)
local Player = game.Players:GetPlayerFromCharacter(t.Parent)
if Player and dbg then
dbg = false
script.Parent.Color = Color3.fromRGB(255,0,0)
local PlayerCharacter = t.Parent
PlayerOldWS = PlayerCharacter["Humanoid"].WalkSpeed
PlayerCharacter["Humanoid"].WalkSpeed = NewWS
wait(Cooldown)
script.Parent.Color = Color3.fromRGB(0,255,0)
PlayerCharacter["Humanoid"].WalkSpeed = PlayerOldWS
dbg = true
end
end)
SpeedPad.rbxl (18.5 KB)
2 Likes
Thank you for the help! I’ll be using this in the future!