local repStore = game:GetService("ReplicatedStorage")
local DSS = game:GetService("DataStoreService")
-- DataStore --
local playerStats = DSS:GetDataStore("playerStats")
local clickStats = DSS:GetDataStore("playerStats", "clickStats")
local rebirthStats = DSS:GetDataStore("playerstats", "rebirthStats")
-- Values --
local rebirthActive = repStore.rebirthActivated
local rebirthMSG = repStore.rebirthMSG
local rebirthStatus = game.StarterGui.Rebirth.rebirthStatus
rebirthStatus.Text = rebirthMSG.Value
local function clicksReset(player)
local leaderStats = player:WaitForChild("leaderstats")
local clicks = leaderStats:WaitForChild("Clicks")
clicks.Value = 0
local clickSuccess, clickErr = pcall(function()
clickStats:SetAsync(player.UserId, clicks.Value)
end)
if clickSuccess then
print("Clicks is now 0")
else
error(clickErr)
end
end
local function rebirthChecker(player)
local leaderStats = player:WaitForChild("leaderstats")
local rebirths = leaderStats:WaitForChild("Rebirths")
rebirths.Value = rebirthStats:GetAsync(player.UserId)
if rebirths.Value == 1 then
rebirths.Value = 2
local rebirthSuccess, rebirthErr = pcall(function()
rebirthStats:SetAsync(player.UserId, rebirths.Value)
end)
if rebirthSuccess then
print("Rebirths is now 2")
else
error(rebirthErr)
end
end
if rebirths.Value == 0 then
rebirths.Value = 1
local rebirthSuccess, rebirthErr = pcall(function()
rebirthStats:SetAsync(player.UserId, rebirths.Value)
end)
if rebirthSuccess then
print("Rebirths is now 1")
else
error(rebirthErr)
end
end
end
rebirthActive.OnServerEvent:Connect(function(player)
local leaderStats = player:WaitForChild("leaderstats")
local clicks = leaderStats:WaitForChild("Clicks")
local rebirths = leaderStats:WaitForChild("Rebirths")
rebirths.Value = rebirthStats:GetAsync(player.UserId)
if clicks.Value >= 2000 and rebirths.Value == 1 then
rebirthStatus.Visible = true
rebirthMSG.Value = "Rebirth Successful!"
rebirthChecker(player)
clicksReset(player)
task.wait(3)
rebirthStatus.Visible = false
else
rebirthStatus.Visible = true
rebirthMSG.Value = "You do not have enough"
task.wait(3)
rebirthStatus.Visible = false
end
if clicks.Value >= 100 and rebirths.Value == 0 then
rebirthStatus.Visible = true
rebirthMSG.Value = "Rebirth Successful!"
rebirthChecker(player)
clicksReset(player)
task.wait(3)
rebirthStatus.Visible = false
else
rebirthStatus.Visible = true
rebirthMSG.Value = "You do not have enough"
task.wait(3)
rebirthStatus.Visible = false
end
end) ```
#Is there way more simpler way to script a rebirth system (one i made is for a clicker simulator)
1 messages · Page 1 of 1 (latest)
this the data save script
local playerStats = DSS:GetDataStore("playerStats")
local clickStats = DSS:GetDataStore("playerStats", "clickStats")
local rebirthStats = DSS:GetDataStore("playerstats", "rebirthStats")
game.Players.PlayerAdded:Connect(function(player)
local success, clicksAmount = pcall(function()
return clickStats:GetAsync(player.UserId)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local leaderStats = player:FindFirstChild("leaderstats")
local clicks = leaderStats:FindFirstChild("Clicks")
local rebirths = leaderStats:FindFirstChild("Rebirths")
local rebirthSuccess, rebirthErr = pcall(function()
rebirthStats:SetAsync(player.UserId, rebirths.Value)
end)
if rebirthSuccess then
print("Player has rebirthed "..rebirths.Value.." times")
else
error(rebirthErr)
end
local clickSuccess, clickErr = pcall(function()
clickStats:SetAsync(player.UserId, clicks.Value)
end)
if clickSuccess then
print("Player now has "..clicks.Value.." clicks")
else
error(clickErr)
end
end)```
I've only done 2 rebirths for this but ye its basically just a continuous pattern