Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local level = game:GetService("DataStoreService"):GetDataStore("Levels")
- local xp = game:GetService("DataStoreService"):GetDataStore("EXP")
- local axp = game:GetService("DataStoreService"):GetDataStore("AXP") -- amount xp needfunction savedata(dataname, playerid, value)
- game:GetService("DataStoreService"):GetDataStore(dataname):SetAsynce(playerid, value)
- endgame.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 = "EXP"
- xpz.Parent = player
- local xpn = Instance.new("IntValue")
- xpn.Value = axp:GetAsync(tostring(player.userId)) or 700
- xpn.Name = "XpNeeded"
- xpn.Parent = player
- xpz.Changed:connect(function()
- if player:WaitForChild("EXP").Value >= player:WaitForChild("XpNeeded") then
- levelz.Value = levelz.value+1
- xpn.Value = xpn.Value+700
- savedata("Levels",player.userid.levelz.Value)
- savedata("EXP",player.userid.xpz.Value)
- savedata("AXP",player.userid.xpn.Value)
- else
- savedata("Levels",player.userid.levelz.Value)
- savedata("EXP",player.userid.xpz.Value)
- savedata("AXP",player.userid.xpn.Value)
- end
- savedata("Levels",player.userid.levelz.Value)
- savedata("EXP",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("EXP",player.userId.player.EXP.Value)
- savedata("AXP",player.userId.player.XpNeeded.Value)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement