I tried to make a rebirth system in my game everything like the multipliers and such work, except actually leveling up. I created a gui that if you click the "okay" button and you have enough coins it will level you up, but it just will not work. There's no errors, or anything. Can someone help?
Server Script:
local datastoreService = game:GetService("DataStoreService")
local CoinsDataStore = datastoreService:GetDataStore("CoinsDataStore")
local ReirthDataStore = datastoreService:GetDataStore("RebirthDataStore")
local rebithed = game.ReplicatedStorage:WaitForChild("Rebirthed")
game.Players.PlayerAdded:Connect(function(player)
local data = Instance.new("Folder",player)
data.Name = "Data"
local folder = Instance.new("Folder",player)
folder.Name = "Values"
local coins = Instance.new("IntValue",data)
coins.Name = "Coins" --Name "Wins" to what ever you want.
coins.Value = 0
local rebirths = Instance.new("IntValue",data)
rebirths.Name = "Rebirths"
rebirths.Value = 0
local fake1 = Instance.new("StringValue",folder)
fake1.Value = tostring(coins.Value)
fake1.Name = tostring(coins.Name)
local thingys = Instance.new("Folder",player)
thingys.Name = "Thing"
local required = Instance.new("IntValue",thingys)
required.Name = "Required"
while wait() do
required.Value = 100 * (rebirths.Value + 1)
end
local data
local data2
local success, errormessage = pcall(function()
data = CoinsDataStore:GetAsync(player.UserId.."-Coins")
data2 = CoinsDataStore:GetAsync(player.UserId.."-Rebirths")
end)
if success then
coins.Value = datalocal datastoreService = game:GetService("DataStoreService")
local CoinsDataStore = datastoreService:GetDataStore("CoinsDataStore")
local ReirthDataStore = datastoreService:GetDataStore("RebirthDataStore")
local rebithed = game.ReplicatedStorage:WaitForChild("Rebirthed")
game.Players.PlayerAdded:Connect(function(player)
local data = Instance.new("Folder",player)
data.Name = "Data"
local folder = Instance.new("Folder",player)
folder.Name = "Values"
local coins = Instance.new("IntValue",data)
coins.Name = "Coins" --Name "Wins" to what ever you want.
coins.Value = 0
local rebirths = Instance.new("IntValue",data)
rebirths.Name = "Rebirths"
rebirths.Value = 0
local fake1 = Instance.new("StringValue",folder)
fake1.Value = tostring(coins.Value)
fake1.Name = tostring(coins.Name)
local thingys = Instance.new("Folder",player)
thingys.Name = "Thing"
local required = Instance.new("IntValue",thingys)
required.Name = "Required"
while wait() do
required.Value = 100 * (rebirths.Value + 1)
end
local data
local data2
local success, errormessage = pcall(function()
data = CoinsDataStore:GetAsync(player.UserId.."-Coins")
data2 = CoinsDataStore:GetAsync(player.UserId.."-Rebirths")
end)
if success then
coins.Value = data
rebirths.Value = data2
else
print("THERE WAS AN ERROR GETTING YOUR DATA STORE.")
warn(errormessage)
end
while wait() do
local x = tostring(coins.Value)
if #x >= 14 then -- Trillions
fake1.Value = x:sub(0,(#x-13)).."."..(x:sub(#x-11,(#x-11))).."T+"
elseif #x >= 10 then --Billions
fake1.Value = x:sub(0,(#x-9)).."."..(x:sub(#x-7,(#x-7))).."B+"
elseif #x >= 7 then --Millions
fake1.Value = x:sub(0,(#x-6)).."."..(x:sub(#x-5,(#x-5))).."M+"
elseif #x >= 4 then --Thousands
fake1.Value = x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
else -- If it's not high enough...
fake1.Value = tostring(coins.Value)
end
end
required.OnServerEvent:Connect(function(player)
if player.Data.Coins.Value >= required.Value then
player.Data.Coins.Value = 0
player.Data.Rebirths.Value = player.Data.Rebirths.Value + 1
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errorMessage = pcall(function()
CoinsDataStore:SetAsync(player.UserId.."-Coins",player.Data.Coins.Value)
ReirthDataStore:SetAsync(player.UserId.."-Rebirths",player.Data.Rebirths.Value)
end)
if success then
print(player.Name.." data saved successfully.")
else
print("There was an error saving data.")
warn(errorMessage)
end
end)
rebirths.Value = data2
else
print("THERE WAS AN ERROR GETTING YOUR DATA STORE.")
warn(errormessage)
end
while wait() do
local x = tostring(coins.Value)
if #x >= 14 then -- Trillions
fake1.Value = x:sub(0,(#x-13)).."."..(x:sub(#x-11,(#x-11))).."T+"
elseif #x >= 10 then --Billions
fake1.Value = x:sub(0,(#x-9)).."."..(x:sub(#x-7,(#x-7))).."B+"
elseif #x >= 7 then --Millions
fake1.Value = x:sub(0,(#x-6)).."."..(x:sub(#x-5,(#x-5))).."M+"
elseif #x >= 4 then --Thousands
fake1.Value = x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
else -- If it's not high enough...
fake1.Value = tostring(coins.Value)
end
end
required.OnServerEvent:Connect(function(player)
if player.Data.Coins.Value >= required.Value then
player.Data.Coins.Value = 0
player.Data.Rebirths.Value = player.Data.Rebirths.Value + 1
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errorMessage = pcall(function()
CoinsDataStore:SetAsync(player.UserId.."-Coins",player.Data.Coins.Value)
ReirthDataStore:SetAsync(player.UserId.."-Rebirths",player.Data.Rebirths.Value)
end)
if success then
print(player.Name.." data saved successfully.")
else
print("There was an error saving data.")
warn(errorMessage)
end
end)
Local Script:
local rebirth = game.ReplicatedStorage.Rebirthed
local db = false
script.Parent.MouseButton1Click:Connect(function()
if db == false then
db = true
rebirth:FireServer()
wait(1)
db = false
end
end)

2 comments
Please include all of your code.
I did it