I need help with setting up a rebirth system

Note; I just need somebody to point me in the correct direction. Nothing else.
I’m looking for a way to connect a rebirth system that adds a multiplier to my tap script and yet adds a rebirth and only takes the coins you have.

I looked up solutions on youtube and the developer forums but I couldn’t find a way to make them work.

Here’s the code I used.

Leaderstats
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = player

local Taps = Instance.new("IntValue")
Taps.Name = "Taps"
Taps.Value = 0
Taps.Parent = leaderstats

local Coins = Instance.new("IntValue")
Coins.Name = "Coins" 
Coins.Value = 0
Coins.Parent = leaderstats

local Rebirths = Instance.new("IntValue")
Rebirths.Name = "Rebirths"
Rebirths.Value = 0
Rebirths.Parent = leaderstats

end)

TapCode1
game.ReplicatedStorage.GiveTaps.OnServerEvent:Connect(function(player)

player.leaderstats.Taps.Value = player.leaderstats.Taps.Value + 1

end)

TapCode2
script.Parent.MouseButton1Click:Connect(function()

game.ReplicatedStorage.GiveTaps:FireServer()

end)

4 Likes

You should add a table called something along the lines of Rebirth table. Encrypt it to JSON using HttpService. Include the variables needed to do this: Rebirths, Multiplier, anything else needed for your circumstances. Then save it using DataStores and you should be good for that stuff. The give taps function should instead of using 1, should use the value of the multiplier on DataStores.

2 Likes

You can create a GUI with a button, when the button is pressed fire a RemoteEvent, and if the player has reached a certain number of taps (im assuming this is what you want), then his points will be set to 0, and his points will go up by his previous point gaining + 1 (or whatever you want). You can simply create a variable for that, and save it in a DataStore, or save his rebirths amount and use a simple formula:

local pointsGaining = 1 + Rebirth.Value --note that this will multiply the points gaining by 1 for each rebirth. You'll also have to create the rebirth value yourself of course, and connect it to a DataStore to save the player's data
game.ReplicatedStorage.GiveTaps.OnServerEvent:Connect(function(player)
   player.leaderstats.Taps.Value = player.leaderstats.Taps.Value + pointsGaining
end)

With my rebirth system you would need to rebirth with the coins you have instead of taps. Taps are just a way to get money. Thank you for trying to help anyway. The script would have to make it so the amount of taps gained per click doubles and the cost of each rebirth would also double.

1 Like

Oh well then you can just implement a coin system. I don’t know how you wanna make it so players will earn coins, but you can just check if the player’s coins have a certain value and if so, remove that value from the coins and follow the code I sent in the last answer. Something like:

local coinsNeeded = 300
local pointsGaining = 1 + Rebirth.Value
    game.ReplicatedStorage.GiveTaps.OnServerEvent:Connect(function(player)
       player.leaderstats.Taps.Value = player.leaderstats.Taps.Value + pointsGaining
   end)

   game.ReplicatedStorage.Rebirth.OnServerEvent:Connect(function(player)
       if Coins.Value >= coinsNeeded then
          Coins.Value = Coins.Value - coinsNeeded
          Rebirths.Value = Rebirths.Value + 1
       end
   end)
5 Likes