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

TeamGUI not working "TeamColor is not a valid member of Players" ?

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Really red") 
end)

I get the TeamColor is not a valid member of Players error. Please help!

1 comment

0

Are you sure you're not parenting to far? As your error is stating that you went back to the service of Players, not the actual player itself. Try removing a "Parent" from line 2. And use Player.TeamColor = TeamName.TeamColor.

2 answers

✓ Accepted answer

I assume since you are using a textButton or ImageButton you are using a local script. With local scripts you can actually get the "local player" by doing this

local player = game:GetService("Players").LocalPlayer

so if you change what you have and use localplayer, you can do this...

local player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	player.TeamColor = BrickColor.new("Really red")
end)

1 comment

0

Remember, LocalPlayer will ONLY work with a localscript; NOT a script. :) Good luck!

Put one Parent property less. Players is a folder that all Player instances stay in. But Players isnt a Player instance. Got it?

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