Why doesn't work this custom leaderboard?

Error Line 32

function onPlayerEntered(newPlayer)

		local stats = Instance.new("IntValue")
		stats.Name = "leaderstats"

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

		local Gold = Instance.new("IntValue")
		Gold.Name = "Gold"
		Gold.Value = 0
		
		local Tix= Instance.new("IntValue")
		Tix.Name = "Tix"
		Tix.Value = 0
		
		local Robux= Instance.new("IntValue")
		Robux.Name = "Robux"
		Robux.Value = 0
		
		local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(newPlayer.Name)
		if cashmoney ~= nil then
			cashmoney.Changed:connect(function()
				Tix.Value = cashmoney.Value
			end)
		end
		
		local TixGold = game.ServerStorage.GoldTixStorage:FindFirstChild(Player.Name)
		if TixGold ~= nil then
			TixGold.Changed:connect(function()
				GoldTix.Value = TixGold.Value
			end)
		end


		local Golds = game.ServerStorage.GoldStorage:FindFirstChild(Player.Name)
		if Golds ~= nil then
			Golds.Changed:connect(function()
				Gold.Value = Golds.Value
			end)
		end


		local Roblox = game.ServerStorage.RobuxStorage:FindFirstChild(newPlayer.Name)
		if Roblox ~= nil then
			Roblox.Changed:connect(function()
				Robux.Value = Roblox.Value
			end)
		end


		GoldTix.Parent = stats
		Gold.Parent = stats
		Tix.Parent = stats
		Robux.Parent = stats

		while true do
			if newPlayer.Character ~= nil then break end
			wait(5)
		end

		stats.Parent = newPlayer
end

game.Players.ChildAdded:connect(onPlayerEntered)

1 comment

0

Try replacing line 67 with game.Players.PlayerAdded:connect(onPlayerEntered).