local level = game:GetService("DataStoreService"):GetDataStore("Levels") local xp = game:GetService("DataStoreService"):GetDataStore("XP") local axp = game:GetService("DataStoreService"):GetDataStore("AXP") -- stands for amount xp needed to level up.
function savedata(dataname, playerid, value) game:GetService("DataStoreService"):GetGlobalDataStore(dataname):SetAsync(playerid, value)
end
game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder") leader.Name = "LeaderStats" leader.Parent = player local levelz = Instance.new("IntValue") levelz.Value = level:GetAsync(tostring(player.userid)) or 1 levelz.Name = "Level" levelz.Parent = player:WaitForChild("Leaderstats") local xpz = Instance.new("NumberValue") xpz.Value = xp:GetAsync(tostring(player.userid)) xpz.Name = "XP" xpz.Parent = player local xpn = Instance.new("IntValue") xpn.Value = axp:GetAsync(tostring(player.userid)) or 700 xpn.Parent = player
xpz.Changed:coonect(function()
if player:WaitForChild("XP").Value >= player:WaitForChild("XpNeeded").Value then
levelz.Value = levelz.Value+1
xpn.Value = xpn.Value+700
savedata("Levels",player.userid,levelz.Value)
savedata("XP",player.userid,xpz.Value)
savedata("AXP",player.userid,xpn.Value)
else
savedata("Levels",player.userid,levelz.Value)
savedata("XP",player.userid,xpz.Value)
savedata("AXP",player.userid,xpn.Value)
end
savedata("Levels",player.userid,levelz.Value)
savedata("XP",player.userid,xpz.Value)
savedata("AXP",player.userid,xpn.Value)
end)
end) game.Players.PlayerRemoving:connect(function(player) savedata("Levels",player.userid,player.leaderstats.Level.Value) savedata("XP",player.userid,player.XP.Value) savedata("AXP",player.userid,player.XpNeeded.Value) end)

2 comments
where should i paste this??? will the rank save , and thank you :)))
you need to make a separate system for the save