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 5 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:

function findTarget()
    local target
    local dist = 100
    for _, p in pairs(workspace:GetChildren()) do
        if p:IsA('Model')
        and p ~= script.Parent
        and p.Name ~= 'BlueNPC'
        --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 — 5y

Answer this question