why doesnt this XP script work, it doesnt work it doesnt show a leader boeard with XP and Level?!
Asked by
8 years ago Edited 8 years ago
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
01 | xpz.Changed:coonect( function () |
02 | if player:WaitForChild( "XP" ).Value > = player:WaitForChild( "XpNeeded" ).Value then |
03 | levelz.Value = levelz.Value+ 1 |
04 | xpn.Value = xpn.Value+ 700 |
05 | savedata( "Levels" ,player.userid,levelz.Value) |
06 | savedata( "XP" ,player.userid,xpz.Value) |
07 | savedata( "AXP" ,player.userid,xpn.Value) |
09 | savedata( "Levels" ,player.userid,levelz.Value) |
10 | savedata( "XP" ,player.userid,xpz.Value) |
11 | savedata( "AXP" ,player.userid,xpn.Value) |
13 | savedata( "Levels" ,player.userid,levelz.Value) |
14 | savedata( "XP" ,player.userid,xpz.Value) |
15 | savedata( "AXP" ,player.userid,xpn.Value) |
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)