#Need help with rebirth system

4 messages · Page 1 of 1 (latest)

scenic saffron
#

I have a rebirth system where if you rebirth (starting cost 100, increases based off of the amount of rebirths you have. ex. i have 5 rebirths so it gives me 5 clickcash on a click) and it works perfectly fine. but if i have 500 clickcash and 5 rebirths, if i rebirth, i get my rebirth but it puts my player's click cash in the negatives. which means that it has to cost 600 clickcash, but i don't know how to make it required. plz help

#
click.OnServerEvent:Connect(function(player)
    player.leaderstats.ClickCash.Value += 1 * player.leaderstats.Rebirths.Value
end)

rebirthEvent.OnServerEvent:Connect(function(player)
    local clickcash = player:WaitForChild("leaderstats"):WaitForChild("ClickCash")
    local rebirths = player:WaitForChild("leaderstats"):WaitForChild("Rebirths")
    local clickUI = player.PlayerGui.ClickME.TextButton
    
    
    if clickcash.Value >= 100 * (rebirths.Value + 100) then -- if the clickcash value is 100 x times the value of your rebirths then
        rebirths.Value += 1 --adds one rebirth
        clickcash.Value -= 100 * rebirths.Value --subtracts 100 x the rebirth value
    else --does something if the player is a fucking pooron
        player.PlayerGui.RebirthUI.Frame.TextButton.Text = "Not enough ClickCash!"
        wait(3)
        player.PlayerGui.RebirthUI.Frame.TextButton.Text = "Rebirth"
    end
end)
gray lintel
#

i mean, you're not doing the sub with the same value as you're checking

#

you're checking if its more than 100 * (rebirths.Value + 100)