Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
6zk8 95
4 years ago
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!

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. killerbrenden 1537 — 4y

2 answers

Log in to vote
0
Answered by
IDKBlox 349 Moderation Voter
4 years ago
Edited 4 years ago

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)
0
Remember, LocalPlayer will ONLY work with a localscript; NOT a script. :) Good luck! IDKBlox 349 — 4y
Ad
Log in to vote
0
Answered by
RAFA1608 543 Moderation Voter
4 years ago

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

Answer this question