Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Leaderboard unknown global 'player' ?

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

✓ Accepted answer

I would simply use a player added function:

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

end)

2 comments

0

I did that but I didn't post that part, its still not working.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.