Serverside:
local Datastore = game:GetService("DataStoreService")
local PlayerValues = Datastore:GetDataStore("PlayerInventory")
local PlayerRestarts = Datastore:GetDataStore("Playerinventory", "Rebirths")
local Event = game.ReplicatedStorage.Text
local Event2 = game.ReplicatedStorage.ObsticalDeleter
local Event3 = game.ReplicatedStorage.NoText
local Restarter = game.ReplicatedStorage.RestartAdder
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local Points = Instance.new("IntValue", leaderstats)
Points.Name = "Points"
Points.Value = 0
local plrPoints = plr.leaderstats.Points
local Restarts = Instance.new("IntValue", leaderstats)
Restarts.Name = "Restarts"
Restarts.Value = 0
Points.Changed:Connect(function()
if Points.Value >= 1 then
Event:FireClient(plr)
else
Event3:FireClient(plr)
end
end)
local success, Error = pcall(function()
PlayerRestarts:SetAsync(plr.UserId, 0)
end)
Restarter.OnServerEvent:Connect(function()
local success, newRestartVal = pcall(function()
return PlayerRestarts:IncrementAsync(plr.UserId, 1)
end)
if success then
Restarts.Value += 1
plrPoints.Value = 0
end
end)
Event2.OnServerInvoke = function(plr)
local fired = false
if plrPoints.Value >= (5 - Restarts.Value) then
plr.leaderstats.Points.Value -= (5 - Restarts.Value)
fired = true
return fired
end
end
end)
** You are now Level 4! **