Need help with Proximity Prompt

Hello! I’m making a robbery system and I am having trouble with adding a Proximity Prompt cooldown.
Here’s the code:

script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
	plr.leaderstats.Cash.Value += 105
end)

Add a Server script inside of the Proximity Prompt and add this code
NOTE: Don’t make it a Local script or else the cooldown will be exploited

local Debounces = {}

script.Parent.Triggered:Connect(function(plr)
if table.find(Debounces, plr.UserId) then return end
table.insert(Debounces, plr.UserId)
	plr.leaderstats.Cash.Value += 105
task.spawn(function()
task.wait(3)
table.remove(Debounces, table.find(Debounces, plr.UserId))
end)
end)
1 Like

Is it a local or server script?

1 Like

Note: I wrote this on my iPad, you may have to format it in studio

local prox = script.Parent
local debounce = false

prox.Triggered:Connect(function(plr)
   if not debounce then
      if debounce == true then
         plr.leaderstats.Cash.Value += 105
         task.wait(COOLDOWN AMOUNT)
         debounce = false
      end
   end
end)

And yes, this is in a serverscript inside your proxprompt

1 Like

Hey! I added this script inside of the proximity prompt, but it doesn’t work. Am I doing something wrong?

This will only work in a Local script meaning it will be exploited.
Server scripts are the way to go.

If he does it on a Server script it will be a cooldown for everybody.

1 Like

What’s the error?
Check the output, Also I don’t know your path find your Proximity prompt.

1 Like

do you want the debounce to be global like, if one player robbed, the others can’t rob only when they wait,
Or,
do you want it so every player can rob even if a recent guy robbed before him.?

1 Like

My script is based on the server

1 Like

The output doesn’t show any errors, even tough there clearly is an error.

It works perfectly fine for me.
Can I see the script?

1 Like

Everybody on the server will have to wait for the Cooldown.

1 Like

ProximityPrompt doesn’t have an event called MouseButton1Click

1 Like

Oh shoot, sorry!

char lint thingy

1 Like

This script doesn’t work either. I tried placing it in Proximity prompt and in the part - neither work.

Try this script

local prox = script.Parent
local debounce = false

prox.Triggered:Connect(function(plr)
   if not debounce then
      debounce = true
         plr.leaderstats.Cash.Value += 105
         task.wait(2)
         debounce = false
   end
end)
1 Like

you still didn’t answer my question,
do you want every player to have a seperated debounce, or all the server are connected to 1 debounce?

1 Like

The cash works, but the cooldown doesn’t work.

I am not a very experienced coder, so I’m not very sure what that means.

you can change the number inside the task.wait() to your number.

1 Like