I've got debounce and this function's running 16 times each time
game.Players.PlayerAdded:Connect(function(player) local MoneyBoard = Instance.new("Folder") MoneyBoard.Name = "leaderstats" local Money = Instance.new("IntValue", MoneyBoard) Money.Name = "Money" Money.Value = 0 MoneyBoard.Parent = player local db = false game.Workspace.MoneyCollector.Touched:Connect(function(hit) if not db then local db = true if hit.Parent:FindFirstChild("HumanoidRootPart") then game.Players:GetPlayerFromCharacter(hit.Parent) if db == true then print(5) end if player then while Money.Value <30000000 do Money.Value = Money.Value + 1000 wait(2) end end end end end) end) local db = false
Remove local from line 12
db = true
Local causes the variable to be changed only within the if statement.