I have a leveling system but, the xp always seems to get smaller and smaller, when the player rejoined, instead of keeping the original Xp.
script:
local Exp = Instance.new(“NumberValue”)
Exp.Name = (“Exp”)
Exp.Parent = plrlocal Level = Instance.new(“NumberValue”)
Level.Name = (“Level”)
Level.Parent = plr
Level.Value = 1local ExpReq = Instance.new(“NumberValue”,plr)
ExpReq.Name = (“ExpRequired”)
ExpReq.Value = Level.Value * 150– Level Up & Exp
Exp.Changed:Connect(function(Changed)
if Exp.Value >= ExpReq.Value then Exp.Value = Exp.Value - ExpReq.Value Level.Value += 1 ExpReq.Value = Level.Value * 150 end
end)
local CoinData
local ExpData
local LevelData
local ExpReqDatalocal worked, Error = pcall(function()
CoinData = myDataStore:GetAsync(plr.UserId.."-Gold") -- Save CoinData -- Save First Coin Given Data ExpData = myDataStore:GetAsync(plr.UserId.."-Exp") LevelData = myDataStore:GetAsync(plr.UserId.."-Level")
end)
if worked == true then
Coin.Value = CoinData Exp.Value = ExpData Level.Value = LevelData ExpReq.Value = ExpReqData
else
warn(Error)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local worked, Error = pcall(function()
myDataStore:SetAsync(player.UserId.."-Exp",player.Exp.Value) myDataStore:SetAsync(player.UserId.."-Level",player.Level.Value) myDataStore:SetAsync(player.UserId.."-ExpRequired",player.ExpRequired.Value)
end)
if worked == true then
else
warn(Error)
end
end)