I have a script, where when a brick is touched you lose money. I would like to make it so that if you don't have over 25 money, you wont lose any. So its like buying something but if you don't have enough, you can't. Anyway, I don't know where to go from here, any help? (Sorry I struggled with the title)
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 cash.Value = cash.Value + moneyToGive wait(2) debounce = false end)
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 >= 25 then --That may have to be if cash.Value <= 25 then cash.Value = cash.Value + moneyToGive wait(2) debounce = false end end)