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 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

01xpz.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)
08    else
09        savedata("Levels",player.userid,levelz.Value)
10        savedata("XP",player.userid,xpz.Value)
11        savedata("AXP",player.userid,xpn.Value)
12    end
13    savedata("Levels",player.userid,levelz.Value)
14    savedata("XP",player.userid,xpz.Value)
15    savedata("AXP",player.userid,xpn.Value)
16end)

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 8 years ago

Try This!

01local xp = Instance.new("IntValue")
02xp.Name = "XP"
03xp.Value= 0
04 
05local level = Instance.new("IntValue")
06level.Name = "Level"
07level.Value = 1
08 
09local c = Instance.new("IntValue")
10c.Name = "Gold"
11c.Value = 0
12 
13Makes you have Level 1, Gold 0 and Xp 0
14 
15 
View all 21 lines...
0
where should i paste this??? will the rank save , and thank you :))) Autobots62 0 — 8y
0
you need to make a separate system for the save arrowman888 69 — 8y
Ad
Log in to vote
0
Answered by 8 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