ServerScript in SSS:

game.Players.PlayerAdded:Connect(function(Player)
	game.ReplicatedStorage.remoteevents.PlayerAdded:FireAllClients(Player) -- fire remoteevent
	Player:GetPropertyChangedSignal("Team"):Connect(function()
		game.ReplicatedStorage.TeamChanged:FireAllClients(Player.Name, Player.Team)
	end)
end)

localscript

game:GetService('ReplicatedStorage').remoteevents.PlayerAdded.OnClientEvent:Connect(function(player)
	local playerLabel = game.ReplicatedStorage.PlayerLabel:Clone()
	playerLabel.Name = player.Name -- this part is where I get the error saying that `player` is nil
	playerLabel.Text = player.Name
	playerLabel.Parent = script.Parent
	local xBounds = playerLabel.TextBounds.X
	playerLabel.TeamColor.BackgroundColor3 = player.Team.TeamColor.Color
	wait()
	playerLabel.TeamColor.Position = UDim2.new(1, -xBounds-5, 0.3, 0)
end)
game.ReplicatedStorage.TeamChanged.OnClientEvent:Connect(function(name, team)
	local frame = script.Parent:FindFirstChild(name)
	frame.TeamColor.BackgroundColor3 = team.TeamColor.Color
end)

2 comments

0

Try printing player a line before the one causing you problems, and see what it prints out

0

the player name prints in both scripts for some reason