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

Attempted to index nil with a "TeamColor", anybody please help?

Hi, I'm working on this VIP server only GUI, and I want the VIP Server owner to have this GUI. The problem is, one of the things in this VIP server only GUI is a team color changer. My script is here:

SCRIPT:

function leftClick()
		--on left click
		local TeamBox = script.Parent.Parent.BlueBox.Text
		--find first child which is related to the blue box
		local TeamPlayer = game.Players:FindFirstChild(TeamBox)
		--change that players team color to "Cyan"
		TeamPlayer.TeamColor = "Cyan"
end
 
script.Parent.MouseButton1Click:Connect(leftClick)

What I want it to do is to change the players team color to blue (Cyan).

Anybody help? Thanks.

1 answer

✓ Accepted answer

Simple mistake. You need to use BrickColor.new.

Here is the fixed version of your script:

function leftClick()
        --on left click
        local TeamBox = script.Parent.Parent.BlueBox.Text
        --find first child which is related to the blue box
        local TeamPlayer = game.Players:FindFirstChild(TeamBox)
        --change that players team color to "Cyan"
        TeamPlayer.TeamColor = BrickColor.new("Cyan")
end

script.Parent.MouseButton1Click:Connect(leftClick)

Hope this helps!

1 comment

0

actually i need it to change the players team, forcing them to join that team

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