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

How to detect Team Color in players?

Asked by 6 years ago

Problem: How do I find team colors in players, and implement them into my script?
Background: I have some NPC’s that won’t attack each other based on a name, but I want to do it so that instead of detecting the name, it detects the team color. It is mostly red vs blue but the bots attack players regardless.
Examples: A blue team NPC will not attack another NPC if the model name is “BlueNPC”, but it will attack everything else with a different name. With this being true, they attack players as they have unique names and they cannot detect team colors as of now.
Script:

1function findTarget()
2    local target
3    local dist = 100
4    for _, p in pairs(workspace:GetChildren()) do
5        if p:IsA('Model')
6        and p ~= script.Parent
7        and p.Name ~= 'BlueNPC'
8        --and p.(How do you find team color in players?)

The rest of the script basically decides either to follow them or not. I have tried to change the name of players when they step on the spawn however their name just reverts back, so that was useless.
It would be a great help to anyone that knows about this, thanks.

0
Im pretty sure theres a property for that, Here is the API: https://developer.roblox.com/api-reference/property/Player/TeamColor MusicalDisplay 173 — 6y

Answer this question