LocalScript
local player = game.Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local eventsFolder = replicatedStorage:WaitForChild("EventsFolder")
local updateEvent = eventsFolder:WaitForChild("UpdateEvent")
local frame = script.Parent
local labels = {}
for i = 1, 10 do
labels[i] = frame:WaitForChild("Player" .. i)
end
function update()
local players = game.Players:GetPlayers()
for number = 1, #labels do
labels[number].Text = tostring(players[number] or "")
labels[number].TextColor3 = players[number].TeamColor.Color -- Error is here
end
end
update()
game.Players.PlayerAdded:connect(update)
game.Players.PlayerRemoving:connect(update)
updateEvent.OnClientEvent:connect(function()
update()
end)
What I am trying to get to happen is make each label a different color, based on the players TeamColor, but it prints this error in the output:
attempt to index field '?' (a nil value)
It currently adds a players name to the list, so that's all working, but I just need it to work so the color of the text is the color of each players team.
If I changed players[numbers] to just player it makes all the TextLabels the color of the local player

1 comment
Some of it works. Only problem, is for 1 player, it works fine, but for the other player, player1, it only shows player1 with a color, and player2 is just white