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.
-- 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
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
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.
| Rebirths done | Coin multiplier | Price of the next rebirth |
|---|---|---|
| 0 | 1x | 1,000 coins |
| 1 | 1.5x | 2,000 coins |
| 2 | 2x | 3,000 coins |
| 5 | 3.5x | 6,000 coins |
| 10 | 6x | 11,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
- Hover over ServerScriptService, click + and insert a Script. Name it
Rebirths. - Paste the code below. It makes the
RequestRebirthRemoteFunction in ReplicatedStorage and theAwardCoinsBindableEvent in ServerStorage when it starts. - 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.
-- 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 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.
-- 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:
| They try | What the server does |
|---|---|
| Call RequestRebirth with 0 coins | Reads its own Coins value, sees it is short, returns "You need 1000 coins". |
| Call it 100 times a second | Accepts at most one a second, and each one still costs the full price. |
| Pass arguments like a cost of 0 | Ignores them: OnServerInvoke only takes the player, which Roblox fills in. |
| Change Coins in their own leaderstats | Only their screen changes. The server's value is the real one, and only it is saved. |
| Fire AwardCoins | They 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
- Press Play. Coins climbs by 5 a second and the button says "Rebirth: 1000 coins (now x1)".
- Click the button before you have 1,000 coins. It says "You need 1000 coins" and nothing changes.
- 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).
- Lower
BASE_COSTto 50 while testing so you do not wait. - Stop and play again: Rebirths should still be 1.
Step 6: Tune and extend it
- Steeper prices: change
costFortoBASE_COST * 2 ^ rebirthsso 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
tryRebirthnext tocoins.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.
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.
- 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
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
- Roblox Creator Docs: Remote events and callbacks. RemoteFunction, InvokeServer and OnServerInvoke
- Roblox Creator Docs: In-experience leaderboards. the leaderstats folder
- Roblox Creator Docs: Data stores. saving and Studio access
- Roblox Creator Docs: Security tactics. why the server checks every request
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.