trying to make it you get level one at 1000 xp and at 2257 xp you get level 2 anything less then 1000 xp is level 0 btw
local level = game:GetService("DataStoreService"):GetDataStore("Levels")
local Xp = game:GetService("DataStoreService"):GetDataStore("Xp")
local axp = game:GetService("DataStoreService"):GetDataStore("AXP")
local RequiredXP = {
[0] = 1000,
[1] = 2257
}
function savedata(dataname, playerid)
game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, Value)
end
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder")
leader.Name = "leaderstats"
leader.Parent = player
local levels = Instance.new("IntValue")
levels.Value = level:GetAsync(tostring(player.userId)) or 1
levels.Name = "Level"
levels.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 1000
xpn.Name = "XpNeeded"
xpn.Parent = player
Xpz.Changed:connect(function()
if player:WaitForChild("Xp").Value >= player:WaitForChild("XpNeeded").Value then
levels.Value = levels.Value+1
xpn.Value = RequiredXP[levels.Value]
savedata("levels",player.userId.levels.Value)
savedata("Xp",player.userId.Axp.Value)
savedata("Axp",player.userId.xpn.Value)
else
savedata("levels",player.userId.levels.Value)
savedata("Xp",player.userId.Axp.Value)
savedata("Axp",player.userId.xpn.Value)
end
end)
end)
