The script quits working after the first touch and I have no idea why. Please help, been stuck trying to figure this out for hours (I'm thinking it has to do with my placement of debounce? Not sure) No one has helped yet!
moneyToGive = -25
debounce = false
script.Parent.Touched:connect(function(hit)
if debounce == true then return end
player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player == nil then return end
stat = player:findFirstChild("leaderstats")
if stat == nil then return end
cash = stat:findFirstChild("Cash")
if cash == nil then return end
debounce = true
if cash.Value <= -26 then
script.Sound2:Play()
debounce = false
end
if cash.Value >= -25 then
cash.Value = cash.Value + moneyToGive
game.Workspace.Desperado.Body.Hay.Transparency = 0
script.Sound:Play()
game.Workspace.Desperado.Body.Cash20l.BillboardGui.Enabled = true
wait(3.5)
game.Workspace.Desperado.Body.Cash20l.BillboardGui.Enabled = false
wait(2)
end
end)

4 comments
because -25 > -26, it's closer to 0, so it goes to the next if statement and then debounce doesn't become false?
I don't know, its a hot mess now.
I don't actually understand debounce all that much. If you couldn't tell.
Line 5 cancels the function if debounce is true. You set debounce to true on line 12 but only set it back to false under only one if statement.