I must be doing something really wrong because this is a huge issue that keeps popping up in my game, but i can’t really find any posts about it.
What do I do if a debounce is in a server script, to make it only affect each specific player?
(e.g. the player goes over a boost pad, the debounce changes to true for 2 seconds, but another player goes over the boost before the debounce is back to false so it doesn’t work for them).
This is a huge issue in many parts of my game so I was wondering if i was just being stupid and there’s an easy fix, or it’s something else entirely. Thanks!
You can create a table inside the script and insert the Players that are on cooldown in there
This would be an example:
local debounce = {}
local function doSomething(Player)
if table.find(debounce,Player) then return end
table.insert(debounce,Player)
task.spawn(function()
task.wait(cooldown)
table.remove(debounce,table.find(debounce,Player))
end)
--Enter code here
end
local db = true
local target = game.Players:WaitForChild("PlayerName")
local part = workspace:WaitForChild("Part")
part.Touched:Connect(function(hit)
if hit.Parent == target.Character and db then
db = false
--
task.wait(2)
db = true
end
end)
Sorry, not sure what you’re looking for here, there was no script to work from.
I guess you want just one person debounced..
ithink there is many ways to solve that issue you can use @sie dev_sie way or add boolvalue called debounce to player whene he join the game and change it whene ever you want
local plrDebounce= {}
local debounceTime = 1
local function doSomething(plr : Player)
if plrDebounce[plr.UserId] then return end
plrDebounce[plr.UserId] = true
--something...
task.delay(1, function()
plrDebounce[plr.UserId] = nil
end)
end```