I have a variable (Cash) inside of this leaderstat function and I want to increase the value of the leaderstat everytime a player touches a part.

I have a variable (Cash) inside of this leaderstat function and I want to increase the value of the leaderstat everytime a player touches a part.

local Players = game:GetService("Players")
local CashGiver = workspace.Teleport1
local Debounce = false
CashGiver.Touched:Connect(function(hit)
if Debounce then return end
if hit and hit.Parent:FindFirstChild("Humanoid") then
local Client = Players:GetPlayerFromCharacter(hit.Parent)
if Client then
Debounce = true
task.delay(1, function()
Debounce = false
end)
Client.leaderstats.Cash.Value += 1
end
end
end)
You absolutely need a debounce for this because Touched is awfully unreliable when it comes to consistency.
thanks, I had tried something similar to this before but it didnt work but this one worked perfectly fine.