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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
DesertusX 435 Moderation Voter
4 years ago

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!

0
actually i need it to change the players team, forcing them to join that team NotRobloxMonch 11 — 4y
Ad

Answer this question