Hello everyone, I'm making a script that will change the players leader board rank when they reach a certain amount of XP, I was recently helped out by berezaa, but I've got stuck again
Here is my script I've been using:
(its not a local script btw)
function onPlayerEntered(newPlayer)
local user = game.Players:findFirstChild(newPlayer)
local stats = user:findFirstChild("leaderstats")
while true do
if stats ~= nil then
local rank = stats:findFirstChild("Rank")
local xp = stats:findFirstChild("XP")
if xp >= 75000 then
rank = "Commanding Officer"
elseif xp >= 65000 then
rank = "General"
elseif xp >= 50000 then
rank = "Admarial"
elseif xp >= 45000 then
rank = "Cononel"
elseif xp >= 35000 then
rank = "Captian"
elseif xp >= 37500 then
rank = "First LT"
elseif xp >= 36500 then
rank = "Second LT"
elseif xp >= 30000 then
rank = "Master Sergeant"
elseif xp >= 25000 then
rank = "Sergeant"
elseif xp >= 23500 then
rank = "Warrant Officer 1"
elseif xp >= 21550 then
rank = "Warrant Officer 2"
elseif xp >= 20000 then
rank = "Corparol"
elseif xp >= 7500 then
rank = "Private First Class"
elseif xp >= 250 then
rank = "Private"
elseif xp >= 550000 then
rank = "Moderator"
elseif xp >= 750000 then
rank = "Administrator"
elseif xp >= 1500000 then
rank = "Head Administrator"
elseif xp >= 3500000 then
rank = "Peace Keeper"
elseif xp >= 5500000 then
rank = "The Victorious"
elseif xp >= 0 then
print("M8 he just getting started!")
end
end
end
end
game.Players.ChildAdded:connect(onPlayerEntered)
If you could help I'd really appreciate it!
There was also an error code:
Workspace.RA.Script:3: attempt to index local 'user' (a nil value)

3 comments
I'll see if it works.
It's not working I've used the script, the only thing I added was the ranks, eg; elseif xp >= 20 then rank = "Private"
Here is the script, local function onPlayerEntered(newPlayer) -- Globals are bad practice. Use locals! local stats = newPlayer:FindFirstChild("leaderstats") -- findFirstChild deprecated local rank = stats.Rank local xp = stats.XP if xp >= 75000 then rank = "Commanding Officer" elseif xp >= 65000 then rank = "General" elseif xp >= 50000 then rank = "Admarial" elseif xp >= 45000 the