Tutorial · Economy

How to make a rebirth system in Roblox Studio

A rebirth (some games say prestige or ascend) lets a player throw away their coins in return for a bonus that lasts forever, usually a multiplier on everything they earn. It is the reason simulator players keep going after they can afford every upgrade. This guide builds a rebirth system that the server controls from start to finish: the price, the reset, the multiplier and the save.

Updated 14 November 20268 min readBeginnerLuauWritten by

In short

Keep Coins and Rebirths in leaderstats from a Script in ServerScriptService. A rebirth button in a LocalScript calls a RemoteFunction with no arguments. The server checks the player has enough coins, sets Coins to 0, adds 1 to Rebirths and returns the result. Every coin reward then goes through one server function that multiplies it by 1 + Rebirths * 0.5. Save Rebirths and Coins in a data store.

  • The client never sends a price or an amount. The server works out the cost from its own numbers.
  • Make each rebirth cost more than the last, or players rebirth forever on the same coins.
  • Add a short cooldown on the server so a cheater spamming the remote cannot do anything strange.

Get the script

Rebirth system script with multiplier and saving

One server Script owns Coins and Rebirths: it sells rebirths through a RemoteFunction after a price check, multiplies every coin reward and saves both numbers.

Script in ServerScriptService named Rebirths
-- Script in ServerScriptService named Rebirths.
-- Owns Coins and Rebirths. Rebirth resets Coins for a permanent coin multiplier.
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local BASE_COST = 1000 -- coins for the first rebirth; each later one costs this much more
local MULTIPLIER_PER_REBIRTH = 0.5 -- 1 rebirth = 1.5x coins, 2 = 2x, and so on
local REBIRTH_COOLDOWN = 1 -- seconds between rebirths for one player
local STORE_NAME = "PlayerRebirths_v1"
local AUTOSAVE_SECONDS = 120

local loaded: { [Player]: boolean } = {}
local lastRebirth: { [Player]: number } = {}

local function store(): DataStore
	return DataStoreService:GetDataStore(STORE_NAME)
end

local function keyFor(player: Player): string
	return "player_" .. player.UserId
end

local function costFor(rebirths: number): number
	return BASE_COST * (rebirths + 1)
end

local function multiplierFor(rebirths: number): number
	return 1 + rebirths * MULTIPLIER_PER_REBIRTH
end

local requestRebirth = Instance.new("RemoteFunction")
requestRebirth.Name = "RequestRebirth"
requestRebirth.Parent = ReplicatedStorage

local awardCoins = Instance.new("BindableEvent")
awardCoins.Name = "AwardCoins"
awardCoins.Parent = ServerStorage

local function getStats(player: Player): (IntValue?, IntValue?)
	local leaderstats = player:FindFirstChild("leaderstats")
	local coins = leaderstats and leaderstats:FindFirstChild("Coins")
	local rebirths = leaderstats and leaderstats:FindFirstChild("Rebirths")
	if coins and coins:IsA("IntValue") and rebirths and rebirths:IsA("IntValue") then
		return coins, rebirths
	end
	return nil, nil
end

-- The button reads these two attributes to show the price and the multiplier
local function updateAttributes(player: Player, rebirths: number)
	player:SetAttribute("RebirthCost", costFor(rebirths))
	player:SetAttribute("CoinMultiplier", multiplierFor(rebirths))
end

-- Every coin reward in the game should come through here, so the multiplier applies
local function addCoins(player: Player, amount: number)
	local coins, rebirths = getStats(player)
	if not (coins and rebirths) then
		return
	end
	if amount ~= amount or amount <= 0 or amount == math.huge then
		return
	end
	coins.Value += math.floor(amount * multiplierFor(rebirths.Value))
end

local function tryRebirth(player: Player): (boolean, string)
	local coins, rebirths = getStats(player)
	if not (coins and rebirths) then
		return false, "Your data is still loading"
	end
	local now = os.clock()
	if now - (lastRebirth[player] or 0) < REBIRTH_COOLDOWN then
		return false, "Slow down"
	end
	lastRebirth[player] = now
	local cost = costFor(rebirths.Value)
	if coins.Value < cost then
		return false, "You need " .. cost .. " coins"
	end
	-- The reset: coins go back to 0, rebirths go up by one
	coins.Value = 0
	rebirths.Value += 1
	updateAttributes(player, rebirths.Value)
	return true, "Rebirth " .. rebirths.Value .. "! Coins now x" .. multiplierFor(rebirths.Value)
end

-- The client sends nothing: the server already knows every number it needs
requestRebirth.OnServerInvoke = function(player: Player): (boolean, string)
	return tryRebirth(player)
end

awardCoins.Event:Connect(function(player: unknown, amount: unknown)
	if typeof(player) == "Instance" and player:IsA("Player") and type(amount) == "number" then
		addCoins(player, amount)
	end
end)

local function onPlayerAdded(player: Player)
	local leaderstats: Instance
	local existing = player:FindFirstChild("leaderstats")
	if existing then
		leaderstats = existing
	else
		leaderstats = Instance.new("Folder")
		leaderstats.Name = "leaderstats"
		leaderstats.Parent = player
	end

	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	local rebirths = Instance.new("IntValue")
	rebirths.Name = "Rebirths"

	local ok, data = pcall(function()
		return store():GetAsync(keyFor(player))
	end)
	if ok then
		if type(data) == "table" then
			coins.Value = math.max(0, math.floor(tonumber(data.Coins) or 0))
			rebirths.Value = math.max(0, math.floor(tonumber(data.Rebirths) or 0))
		end
		loaded[player] = true
	else
		warn("Could not load rebirths for " .. player.Name .. ": " .. tostring(data))
	end

	coins.Parent = leaderstats
	rebirths.Parent = leaderstats
	updateAttributes(player, rebirths.Value)
end

local function save(player: Player)
	if not loaded[player] then
		return
	end
	local coins, rebirths = getStats(player)
	if not (coins and rebirths) then
		return
	end
	local ok, err = pcall(function()
		store():SetAsync(keyFor(player), { Coins = coins.Value, Rebirths = rebirths.Value }, { player.UserId })
	end)
	if not ok then
		warn("Could not save rebirths for " .. player.Name .. ": " .. tostring(err))
	end
end

Players.PlayerAdded:Connect(onPlayerAdded)
for _, player in Players:GetPlayers() do
	task.spawn(onPlayerAdded, player)
end

Players.PlayerRemoving:Connect(function(player: Player)
	save(player)
	loaded[player] = nil
	lastRebirth[player] = nil
end)

task.spawn(function()
	while true do
		task.wait(AUTOSAVE_SECONDS)
		for _, player in Players:GetPlayers() do
			task.spawn(save, player)
		end
	end
end)

game:BindToClose(function()
	local pending = 0
	for _, player in Players:GetPlayers() do
		pending += 1
		task.spawn(function()
			save(player)
			pending -= 1
		end)
	end
	while pending > 0 do
		task.wait()
	end
end)

RoCode builds it in the place you have open in Roblox Studio, on Windows or macOS with a desktop browser; on a phone the button sends the prompt and the link to your computer. Free to start, with free credits every day. More Roblox Studio scripts

Where to put it

Explorer: the script makes both events
ServerScriptService
  Rebirths Script new
ServerStorage
  AwardCoins BindableEvent (made by the script)
ReplicatedStorage
  RequestRebirth RemoteFunction (made by the script)
StarterGui
  RebirthButton LocalScript new

Settings you can change

BASE_COSTIn the script
Coins the first rebirth costs. Each rebirth after that costs this much more. Default: 1000.
MULTIPLIER_PER_REBIRTHIn the script
Extra multiplier per rebirth: 0 rebirths earn 1x, 1 earns 1.5x, 4 earn 3x. Default: 0.5.
REBIRTH_COOLDOWNIn the script
Seconds the server waits before it accepts another rebirth from the same player. Default: 1.

Saving needs Enable Studio Access to API Services on in Studio (Step 5). Give coins from your other scripts with AwardCoins:Fire(player, amount) so the multiplier applies (Step 3).

What a cheater can and cannot doThe button only asks. The server reads its own Coins and Rebirths, works out the price and refuses if the player cannot pay, so a cheater firing the RemoteFunction gets nothing extra (why it is safe).

Type-checked with luau-lsp strict against Roblox's API definitions on 14 November 2026. Not playtested in Studio yet: press Play and watch the Output window before you publish.

Prompt for RoCode

Add a rebirth system to my game: one Script in ServerScriptService that owns Coins and Rebirths in leaderstats, a RequestRebirth RemoteFunction in ReplicatedStorage that resets Coins to 0 and adds a rebirth when the server sees enough coins, a cost of 1000 times the next rebirth number, a coin multiplier of 1 plus 0.5 per rebirth applied by an AwardCoins BindableEvent in ServerStorage, a 1 second cooldown, saving in a data store, and a rebirth button that shows the price.

On this page
  1. Get the script
  2. How it works
  3. 1. Server script
  4. 2. Button
  5. 3. Earn coins
  6. 4. Security
  7. 5. Test
  8. 6. Extend
  9. Common errors
  10. With RoCode
  11. Questions
  12. Sources

How a rebirth system works

A rebirth has three parts. A price: the coins a player needs. A reset: those coins (and often upgrades) go back to zero. A reward: a bonus that stays, here a multiplier on every coin the player earns from then on.

With BASE_COST 1000 and MULTIPLIER_PER_REBIRTH 0.5
Rebirths doneCoin multiplierPrice of the next rebirth
01x1,000 coins
11.5x2,000 coins
22x3,000 coins
53.5x6,000 coins
106x11,000 coins

The price grows a little faster than the multiplier at first, then the multiplier catches up, so each rebirth takes about the same time once a player has a few. If you want rebirths to slow down over time, make the price grow faster (Step 6).

Step 1: The rebirth script

  1. Hover over ServerScriptService, click + and insert a Script. Name it Rebirths.
  2. Paste the code below. It makes the RequestRebirth RemoteFunction in ReplicatedStorage and the AwardCoins BindableEvent in ServerStorage when it starts.
  3. If your game already has a script that makes Coins in leaderstats, remove Coins from that script: two scripts writing the same value fight each other. This one owns Coins from now on.
Script in ServerScriptService named Rebirths
-- Script in ServerScriptService named Rebirths.
-- Owns Coins and Rebirths. Rebirth resets Coins for a permanent coin multiplier.
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local BASE_COST = 1000 -- coins for the first rebirth; each later one costs this much more
local MULTIPLIER_PER_REBIRTH = 0.5 -- 1 rebirth = 1.5x coins, 2 = 2x, and so on
local REBIRTH_COOLDOWN = 1 -- seconds between rebirths for one player
local STORE_NAME = "PlayerRebirths_v1"
local AUTOSAVE_SECONDS = 120

local loaded: { [Player]: boolean } = {}
local lastRebirth: { [Player]: number } = {}

local function store(): DataStore
	return DataStoreService:GetDataStore(STORE_NAME)
end

local function keyFor(player: Player): string
	return "player_" .. player.UserId
end

local function costFor(rebirths: number): number
	return BASE_COST * (rebirths + 1)
end

local function multiplierFor(rebirths: number): number
	return 1 + rebirths * MULTIPLIER_PER_REBIRTH
end

local requestRebirth = Instance.new("RemoteFunction")
requestRebirth.Name = "RequestRebirth"
requestRebirth.Parent = ReplicatedStorage

local awardCoins = Instance.new("BindableEvent")
awardCoins.Name = "AwardCoins"
awardCoins.Parent = ServerStorage

local function getStats(player: Player): (IntValue?, IntValue?)
	local leaderstats = player:FindFirstChild("leaderstats")
	local coins = leaderstats and leaderstats:FindFirstChild("Coins")
	local rebirths = leaderstats and leaderstats:FindFirstChild("Rebirths")
	if coins and coins:IsA("IntValue") and rebirths and rebirths:IsA("IntValue") then
		return coins, rebirths
	end
	return nil, nil
end

-- The button reads these two attributes to show the price and the multiplier
local function updateAttributes(player: Player, rebirths: number)
	player:SetAttribute("RebirthCost", costFor(rebirths))
	player:SetAttribute("CoinMultiplier", multiplierFor(rebirths))
end

-- Every coin reward in the game should come through here, so the multiplier applies
local function addCoins(player: Player, amount: number)
	local coins, rebirths = getStats(player)
	if not (coins and rebirths) then
		return
	end
	if amount ~= amount or amount <= 0 or amount == math.huge then
		return
	end
	coins.Value += math.floor(amount * multiplierFor(rebirths.Value))
end

local function tryRebirth(player: Player): (boolean, string)
	local coins, rebirths = getStats(player)
	if not (coins and rebirths) then
		return false, "Your data is still loading"
	end
	local now = os.clock()
	if now - (lastRebirth[player] or 0) < REBIRTH_COOLDOWN then
		return false, "Slow down"
	end
	lastRebirth[player] = now
	local cost = costFor(rebirths.Value)
	if coins.Value < cost then
		return false, "You need " .. cost .. " coins"
	end
	-- The reset: coins go back to 0, rebirths go up by one
	coins.Value = 0
	rebirths.Value += 1
	updateAttributes(player, rebirths.Value)
	return true, "Rebirth " .. rebirths.Value .. "! Coins now x" .. multiplierFor(rebirths.Value)
end

-- The client sends nothing: the server already knows every number it needs
requestRebirth.OnServerInvoke = function(player: Player): (boolean, string)
	return tryRebirth(player)
end

awardCoins.Event:Connect(function(player: unknown, amount: unknown)
	if typeof(player) == "Instance" and player:IsA("Player") and type(amount) == "number" then
		addCoins(player, amount)
	end
end)

local function onPlayerAdded(player: Player)
	local leaderstats: Instance
	local existing = player:FindFirstChild("leaderstats")
	if existing then
		leaderstats = existing
	else
		leaderstats = Instance.new("Folder")
		leaderstats.Name = "leaderstats"
		leaderstats.Parent = player
	end

	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	local rebirths = Instance.new("IntValue")
	rebirths.Name = "Rebirths"

	local ok, data = pcall(function()
		return store():GetAsync(keyFor(player))
	end)
	if ok then
		if type(data) == "table" then
			coins.Value = math.max(0, math.floor(tonumber(data.Coins) or 0))
			rebirths.Value = math.max(0, math.floor(tonumber(data.Rebirths) or 0))
		end
		loaded[player] = true
	else
		warn("Could not load rebirths for " .. player.Name .. ": " .. tostring(data))
	end

	coins.Parent = leaderstats
	rebirths.Parent = leaderstats
	updateAttributes(player, rebirths.Value)
end

local function save(player: Player)
	if not loaded[player] then
		return
	end
	local coins, rebirths = getStats(player)
	if not (coins and rebirths) then
		return
	end
	local ok, err = pcall(function()
		store():SetAsync(keyFor(player), { Coins = coins.Value, Rebirths = rebirths.Value }, { player.UserId })
	end)
	if not ok then
		warn("Could not save rebirths for " .. player.Name .. ": " .. tostring(err))
	end
end

Players.PlayerAdded:Connect(onPlayerAdded)
for _, player in Players:GetPlayers() do
	task.spawn(onPlayerAdded, player)
end

Players.PlayerRemoving:Connect(function(player: Player)
	save(player)
	loaded[player] = nil
	lastRebirth[player] = nil
end)

task.spawn(function()
	while true do
		task.wait(AUTOSAVE_SECONDS)
		for _, player in Players:GetPlayers() do
			task.spawn(save, player)
		end
	end
end)

game:BindToClose(function()
	local pending = 0
	for _, player in Players:GetPlayers() do
		pending += 1
		task.spawn(function()
			save(player)
			pending -= 1
		end)
	end
	while pending > 0 do
		task.wait()
	end
end)

tryRebirth is the whole rebirth: it checks the cooldown, works out the price from the server's own Rebirths value, refuses if Coins is short, and otherwise resets Coins and adds a rebirth. It returns true or false and a message, which the RemoteFunction sends back to the button.

Step 2: The rebirth button

The button shows the price and the current multiplier, and calls the RemoteFunction when clicked. It builds itself in code so you can paste it and play.

  1. Hover over StarterGui, click + and insert a LocalScript. Name it RebirthButton.
  2. Paste the code below.
LocalScript in StarterGui named RebirthButton
-- LocalScript in StarterGui named RebirthButton.
-- Shows the price and multiplier, and asks the server to rebirth. It never sends numbers.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local requestRebirth = ReplicatedStorage:WaitForChild("RequestRebirth") :: RemoteFunction

local gui = Instance.new("ScreenGui")
gui.Name = "RebirthGui"
gui.ResetOnSpawn = false

local button = Instance.new("TextButton")
button.AnchorPoint = Vector2.new(1, 0.5)
button.Position = UDim2.new(1, -16, 0.5, 0)
button.Size = UDim2.fromOffset(200, 64)
button.BackgroundColor3 = Color3.fromRGB(255, 170, 40)
button.TextColor3 = Color3.new(1, 1, 1)
button.Font = Enum.Font.GothamBold
button.TextSize = 16
button.TextWrapped = true
button.Parent = gui
Instance.new("UICorner").Parent = button

gui.Parent = player:WaitForChild("PlayerGui")

local busy = false

local function refresh()
	if busy then
		return
	end
	local cost = player:GetAttribute("RebirthCost")
	local multiplier = player:GetAttribute("CoinMultiplier")
	if type(cost) == "number" and type(multiplier) == "number" then
		button.Text = "Rebirth: " .. cost .. " coins (now x" .. multiplier .. ")"
	else
		button.Text = "Loading..."
	end
end

button.Activated:Connect(function()
	if busy then
		return
	end
	busy = true
	local ok, _, message = pcall(function()
		return requestRebirth:InvokeServer()
	end)
	if ok and type(message) == "string" then
		button.Text = message
	else
		button.Text = "Try again"
	end
	task.wait(1.5)
	busy = false
	refresh()
end)

player:GetAttributeChangedSignal("RebirthCost"):Connect(refresh)
player:GetAttributeChangedSignal("CoinMultiplier"):Connect(refresh)
refresh()

InvokeServer waits for the server's answer, which is why the button can show "You need 3000 coins" or "Rebirth 3!" right away. It is wrapped in pcall because an invoke can fail if the server script errors. busy stops a player from clicking again before the answer arrives.

Step 3: Earn coins with the multiplier

A multiplier only works if every coin goes through it. Instead of writing coins.Value += 10 in your coin scripts, fire the AwardCoins BindableEvent. The Rebirths script multiplies the amount and adds it.

This example pays every player 5 coins a second, which is enough to try rebirths. Replace it with your own coins, clicks or drops.

Script in ServerScriptService named CoinIncome
-- Script in ServerScriptService named CoinIncome.
-- Pays every player a few coins each second, multiplied by their rebirths.
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

local COINS_PER_SECOND = 5

local awardCoins = ServerStorage:WaitForChild("AwardCoins") :: BindableEvent

while true do
	task.wait(1)
	for _, player in Players:GetPlayers() do
		awardCoins:Fire(player, COINS_PER_SECOND)
	end
end

A player with 2 rebirths now earns 10 coins a second. Coin parts work the same way: the coin collect guide adds coins in one place, so change that line to awardCoins:Fire(player, value).

Step 4: Why a cheater cannot fake a rebirth

An exploiter can fire any RemoteEvent or RemoteFunction in your game, as often as they like, with any arguments. Walk through what that gets them here:

What an exploiter can try
They tryWhat the server does
Call RequestRebirth with 0 coinsReads its own Coins value, sees it is short, returns "You need 1000 coins".
Call it 100 times a secondAccepts at most one a second, and each one still costs the full price.
Pass arguments like a cost of 0Ignores them: OnServerInvoke only takes the player, which Roblox fills in.
Change Coins in their own leaderstatsOnly their screen changes. The server's value is the real one, and only it is saved.
Fire AwardCoinsThey cannot: it is in ServerStorage, which clients never receive.

The most common rebirth bug in copied scripts is a remote that takes the new values from the client, like Rebirth:FireServer(newCoins, newRebirths). Never do that. For more on checking what clients send, see the RemoteEvents guide and the anti-exploit guide.

Step 5: Test it

  1. Press Play. Coins climbs by 5 a second and the button says "Rebirth: 1000 coins (now x1)".
  2. Click the button before you have 1,000 coins. It says "You need 1000 coins" and nothing changes.
  3. Wait until Coins passes 1,000 and click. Coins goes to 0, Rebirths goes to 1, and Coins now climbs by 7 a second (5 times 1.5, rounded down).
  4. Lower BASE_COST to 50 while testing so you do not wait.
  5. Stop and play again: Rebirths should still be 1.

Step 6: Tune and extend it

  • Steeper prices: change costFor to BASE_COST * 2 ^ rebirths so each rebirth costs double the last. Players then rebirth less often but every one feels bigger.
  • Reset upgrades too: if your game sells upgrades, reset them in tryRebirth next to coins.Value = 0. Keep anything bought with Robux, such as game passes.
  • A rebirth currency: give a second currency on rebirth (gems, say) and sell permanent upgrades for it. Save it the same way.
  • Levels instead of coins: the same pattern resets a level for a bonus. Start from the XP and level system.

For a full simulator loop with clicks, upgrades and rebirths in one place, see the simulator game guide.

Common errors and fixes

Check the Output window first: a red line names the script and the line.

The button says Loading... forever

The attributes come from the Rebirths script. Make sure it is a Script in ServerScriptService and has no red error in the Output.

Coins jump back after a rebirth

Another script also sets Coins, for example an old leaderstats script that saves its own copy. Remove Coins from it so only the Rebirths script owns that value.

Coins go up without the multiplier

That coin script changes Coins.Value directly. Fire AwardCoins instead (Step 3).

InvokeServer errors or never returns

The RemoteFunction must be named RequestRebirth and sit in ReplicatedStorage, and only one script may set OnServerInvoke. A second script setting it replaces the first.

Build it with RoCode

If you would rather not wire it up by hand, RoCode can add this to the place you have open. RoCode is an independent AI agent for Roblox Studio, not made by Roblox: you describe the change in a web chat, and its Studio plugin creates the scripts in your Explorer.

You type

Add rebirths to my simulator: 1000 coins for the first, more each time, each rebirth adds 0.5x to all coins earned, a rebirth button on the right with the price, saved.

RoCode does
  • Can read your place first to find the scripts that give coins and route them through the multiplier
  • Writes the scripts with Create Script and is told to compile-check each one with Check Script
  • Sets an undo point before and after each batch of changes, so Ctrl+Z steps back one batch at a time

How RoCode connects to Studio.

Questions

How do I make a rebirth system in Roblox Studio?

A server Script owns Coins and Rebirths, a RemoteFunction lets the client ask for a rebirth, and the server checks the coins, resets them and adds a rebirth. Step 1 has the full script.

How do rebirth multipliers work?

Every coin reward is multiplied before it is added, here by 1 + Rebirths * 0.5. That only works if all coins go through one function, which is what the AwardCoins event is for.

Should rebirth use a RemoteEvent or a RemoteFunction?

Either is safe if the server checks the price. A RemoteFunction is handy because the button gets an answer straight back, such as "You need 2000 coins".

How do I save rebirths?

Save Rebirths with Coins in a data store when the player leaves, every few minutes and when the server closes, as the Rebirths script does. The DataStore tutorial explains the rules.

What should a rebirth reset?

Usually coins and coin upgrades. Keep anything a player paid Robux for, badges and their rebirth count.

Sources and further reading

How the code was checked: every script on this page passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 14 November 2026). A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.

Try RoCode on your own place.

Free every day, no card required. Install the plugin, describe the feature, and review what lands in Studio.