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

Adding a Brick Color to player?

Asked by 4 years ago
Edited 4 years ago

I'm trying to get it to where when a player joins or when a player is on a team, that they automatically get a Brick Color added to them, that way I can have the NPC track down the Brick Color instead of "Humanoid" so the NPC's don't all kill each other but will go after the Players instead.

`local Players = game:GetService("Players") local Teams = game:GetService("Teams")

for _, Player in pairs(Players) do if Player.TeamColor == BrickColor.new("Bright red") then BrickColor.new("Bright red") end end`

Is what I cooked up & put in StarterCharacterScripts.. going to try to put in a diff location BUT...

It tells me the error while in StarterCharacterScripts " Workspace.Player'sName.LocalScript:5: bad argument #1 (table expected, got Object)"

Player'sName was my name I just replaced it.

--edit I tried putting it just in workspace and it didn't work either.. :(

I'm trying to do it this way because I cannot figure out a code to get the NPC to follow a teamcolor instead of a Humanoid

0
You have to use Players:GetPlayers() to get the table of all the players. Right now what you are doing is putting a service (Players) where a table should be, resulting in the error you are getting. Just change it to for_,Player in pairs(Players:GetChildren()) do Sulu710 142 — 4y
0
Thank you!! No more error! AngeloidX3 0 — 4y

Answer this question