Hi, I made a Rebirth System, But, how do i double the price each time

Viewed 47
script.Parent.MouseButton1Click:Connect(function()
    if game.Players.LocalPlayer.leaderstats.Clicks.Value < 300 then
        script.Parent.Text = "Not Enough!"
        wait(2)
        script.Parent.Text = "1 REBIRTH          │       500  CLICKS"
    end
    if  game.Players.LocalPlayer.leaderstats.Clicks.Value >= 300 then       
        game.Players.LocalPlayer.leaderstats.Rebirths.Value =  game.Players.LocalPlayer.leaderstats.Rebirths.Value +1
        game.Players.LocalPlayer.leaderstats.Clicks.Value = 0
        game.Players.LocalPlayer.leaderstats.Gems.Value =  game.Players.LocalPlayer.leaderstats.Gems.Value + 10
    end 
end)
2 Answers

All you need to do is multiply by two, not add by one. Try this:

script.Parent.MouseButton1Click:Connect(function() if game.Players.LocalPlayer.leaderstats.Clicks.Value < 300 then

    script.Parent.Text = "Not Enough!"
    wait(2)
    script.Parent.Text = "1 REBIRTH          │       500  CLICKS"
    end
if  game.Players.LocalPlayer.leaderstats.Clicks.Value >= 300 then       
    game.Players.LocalPlayer.leaderstats.Rebirths.Value =  game.Players.LocalPlayer.leaderstats.Rebirths.Value *2
    game.Players.LocalPlayer.leaderstats.Clicks.Value = 0
    game.Players.LocalPlayer.leaderstats.Gems.Value =  game.Players.LocalPlayer.leaderstats.Gems.Value + 10
    end 
end)

You need to calculate the cost of the next rebirth using the values available to you. Then you need to update the text and the cost based on those values.

script.Parent.MouseButton1Click:Connect(function()
    local leaderstats = game.Players.LocalPlayer.leaderstats
    local clicks = leaderstats.Clicks
    local rebirths = leaderstats.Rebirths
    local gems = leaderstats.Gems

    local baseRebirthCost = 300
    local currentRebirthCost = baseRebirthCost * (2 ^ rebirths.Value)

    if clicks.Value < currentRebirthCost then
        script.Parent.Text = "Not Enough!"
        wait(2)
        script.Parent.Text = string.format("1 REBIRTH          │       %d  CLICKS", currentRebirthCost)
    else      
        rebirths.Value += 1
        clicks.Value = 0
        gems.Value += 10
    end 
end)

This will make the rebirth cost increase relative to the number of rebirths :

Rebirths Calculation Cost
0 300 * 2^0 300
1 300 * 2^1 600
2 300 * 2^2 1,200
3 300 * 2^3 2,400
4 300 * 2^4 4,800
... ... ...
20 300 * 2^20 314,572,800
Related