I added a debounce for my script to give a leaderstat a value and here is what it looks like. I have the wait loop there however it doesn’t seem to be running.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Cash = Instance.new("IntValue", leaderstats)
Cash.Name = "Cash"
Cash.Value = 0
Cash.Parent = leaderstats
local Players = game:GetService("Players")
local CashGiver = game.Workspace.Teleport1
local debounce = false
-- Giving the player cash after touching teleporter
CashGiver.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") then
local Client = Players:GetPlayerFromCharacter(hit.Parent)
if Client then
-- Waits three seconds before reseting
if not debounce then
local debounce = true
Cash.Value = Cash.Value + 20
print("Player was given twenty cash")
wait(3)
local debounce = false
end
end
end
end)
end)