You could “harcode” it in a table, like so:
local rebirthPointCost = {
[1] = 5000,
[2] = 10000,
[3] = 20000,
[4] = 50000,
}
You could also write the table like so:
local rebirthPointCost = { 5000, 10000, 20000, 50000 }
But that makes it less readable IMO.
You can then set up your rebirth code like this:
game.ReplicatedStorage.RebirthEvent.OnServerEvent:connect(function(player)
local rebirths = player.leaderstats.rebirths
local points = player.leaderstats.Points
local rebirthPointCost = rebirthPointCosts[rebirths.Value + 1]
if rebirthPointCost then
if points.Value >= rebirthPointCost then
rebirths.Value += 1
points.Value = 0
end
else
warn(("No rebirth cost coded for rebirth number %d, cannot rebirth!"):format(rebirths.Value + 1))
end
end)
Another approach is to use a mathematical function, like an exponential or power function. This has the advantage that in most cases you can evaluate the function at any rebirth number, so you can potentially have infinite rebirths with costs that keep growing.
E.g. here’s the function (50x)^2
And the code to use it could look like this:
game.ReplicatedStorage.RebirthEvent.OnServerEvent:connect(function(player)
local rebirths = player.leaderstats.rebirths
local points = player.leaderstats.Points
local rebirthPointCost = (50 * (rebirths.Value + 1))^2
if rebirthPointCost then
if points.Value >= rebirthPointCost then
rebirths.Value += 1
points.Value = 0
end
else
warn(("No rebirth cost coded for rebirth number %d, cannot rebirth!"):format(rebirths.Value + 1))
end
end)
I recommend using some kind of graphing software to play around with and tweak different functions to get progressions that you like.