I've been trying to make a Click for Cash button in Roblox, only to find out that the cooldown/debounce can also happen to other players. I've tried switching the Scripts to Local Scripts, but it does not work (I'm a beginner at coding) This is my code right now (Getting Money Script):
local cooldown = false
local COOLDOWN_TIME = 10
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local clickDetector = script.Parent.ClickDetector
local timeRemaining = 10
clickDetector.MouseClick:Connect(function(player)
if cooldown == false then
cooldown = true
player.leaderstats.Money.Value = player.leaderstats.Money.Value + math.random(1,200) * math.random(1,500) - math.random(1,5000)
repeat
print(timeRemaining)
wait(1)
timeRemaining = timeRemaining - 1
until timeRemaining == 0
if timeRemaining == 0 then
cooldown = false
timeRemaining = 10
else
return
end
elseif cooldown == true then
return
end
end)
(Cooldown Appearance Script):
local cooldown = false
local CD = script.Parent.ClickDetector
CD.MouseClick:Connect(function()
if cooldown == false then
cooldown = true
for count = 10, 0, -1 do
script.Parent.Parent.ClickGiveMoneyBase.BillboardGui.TextLabel.Text = count
wait(1)
end
script.Parent.Parent.ClickGiveMoneyBase.BillboardGui.TextLabel.Text = "Click this Button to Give you CASH!"
cooldown = false
elseif cooldown == true then
return
end
end)
More clearance to my problem: When a player clicks and cooldown happens, it not only happens on the player that clicked the part, but also on other players in the server.

5 comments
WHY DOWNVOTE
Hello there! I don't know how to change the scripts to work via remote function. Can you help with this? (I have McDonald's-level WiFi so I can't open ROBLOX Studio yet)
Also I didn't downvote you.
Nvm, fixed it.
Nevermind the nvm, cooldown still appears on other ppl.