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

Leaderboard unknown global 'player' ?

Asked by 6 years ago

How can I identify "player" on XP.Changed function?

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

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

local XPN = Instance.new("IntValue")
XPN.Name = "XPN"
XPN.Value = 500
XPN.Parent = stats

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

XP.Changed:connect(function()
    if player:WaitForChild("XP").Value >= player:WaitForChild("XPN").Value then
        Level.Value = Level.Value+1
        XPN.Value = XPN.Value+500
    end
end)

end)

1 answer

Log in to vote
0
Answered by
oftenz 367 Moderation Voter
6 years ago

I would simply use a player added function:

game.Players.PlayerAdded:connect(function(player)

end)
0
I did that but I didn't post that part, its still not working. xSanjiVinsmoke 4 — 6y
0
Ah sorry, I saw that instead of "(player)" it was using "(p)" so thats why it didnt work! Thank you very much for that answer. xSanjiVinsmoke 4 — 6y
Ad

Answer this question