Player only CD on click detector

Currently if you do a debounce its global onto the clickdetector for any other player, how would I be able to make it player only?

You can make it player only with a local script
local Debounce = false
ClickDetector.MouseClick:Connect(function()
if Debounce == false then
Debounce = true
– Put your code here
wait(3) – Put the delay here
Debounce = false
end
end)

To add onto @sparklenico20, you should use a localscript to change a debounce locally, but if you require that the code does something serversided, you need to fire a RemoteEvent. I recommend reading this article if you don’t know how use them.

Make sure you place your LocalScript in a location that can be used by a LocalScript, they are as follows

  • The player’s character via StarterCharacterScripts
  • StarterPlayerScripts
  • ReplicatedFirst
  • StarterGuo
  • The backpack, mostly for tools

Anywhere else the localscript will refuse to run

Edit: Oh how we missed the simplest answer, what @legs_v is the best way to do it the simplest, use that and it should work

1 Like

Just use a table to store every player and then set it to false afterwards no need for remote events or local scripts

local debounceTable = {}

clickedsmthidk:Connect(function(player)
  if not debounceTable[player.Name] then
    debounceTable[player.Name] = true
    -- code
    wait() -- debounce cooldown
    debounceTable[player.Name] = false
  end
end)
3 Likes

You shouldn’t do debounce on the client, not at all. Hackers can easily use getsenv on the script, set debounce to false and spam the click detector