I'm trying to make players on the green team glow with a green light, but when I do, I get the error "charname is not a valid member of Players". What i'm trying to do is have the script find the name of the player (from the model), then find the corresponding player in game.Players.
function onRespawn(Character)
if (Character:findFirstChild("LowerTorso") ~= nil) then
local charname = Character.Name
local playerteam = game.Players.charname.Team
if playerteam == "Green" then
local light = Instance.new("PointLight")
light.Parent = Character.LowerTorso
light.Range = 15
light.Brightness = 10
light.Color = Color3.new(0,255,0)
end
end
if (Character:findFirstChild("LowerTorso") == nil) then
end
end
game.Workspace.ChildAdded:connect(onRespawn)

4 comments
Doesn't work.
Answer edited; the value of player.Team is a Team Object, not a string, as I took from your original code. Next time, try editing the code. Fix was simple.
I did edit it and I though that was what you were checking for.
Fair enough