Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why doesnt this XP script work, it doesnt work it doesnt show a leader boeard with XP and Level?!

Asked by 7 years ago
Edited 7 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

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 answers

Log in to vote
1
Answered by 7 years ago

Try This!

local xp = Instance.new("IntValue") 
xp.Name = "XP" 
xp.Value= 0 

local level = Instance.new("IntValue") 
level.Name = "Level" 
level.Value = 1 

local c = Instance.new("IntValue") 
c.Name = "Gold" 
c.Value = 0 

Makes you have Level 1, Gold 0 and Xp 0 


function onXPChanged(player, XP, level) 
if Xp.Value>=level.Value * 10 then 
Xp.Value = Xp.value - level.Value * 10 
level.Value = level.Value + 1 
end 
end

0
where should i paste this??? will the rank save , and thank you :))) Autobots62 0 — 7y
0
you need to make a separate system for the save arrowman888 69 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

Is doesn't work because you wrote player.userId with a lowercase i. Try to rewrite it with a capital.

Answer this question