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

How would I detect for there being another team with the same teamcolor?

Asked by 5 years ago

Hello! I need to figure out how to make a "Create Team" system, I currently have a gui and everything, however i need to check if there are other teams of the same teamcolor. I tried using a for loop which didn't work, but i may have messed it up or something. Along with that, im running this by using a localscript to fire a remote event which leads to this.

function createcrew(player,color)
    print("buy")
    if player.leaderstats.Doubloons.Value >= 5 then

        print("money")
        player.leaderstats.Doubloons.Value = player.leaderstats.Doubloons.Value - 5
        local team = Instance.new("Team")
        team.AutoAssignable = false
        team.TeamColor = color
        team.Parent = game.Teams
        team.Name = player.Name.."'s Crew"
        player.Team = team
        player.Neutral = false
        local owner = Instance.new("StringValue")
        owner.Name = "Owner"
        owner.Value = player.Name
        owner.Parent = team



    end


end
game.ReplicatedStorage.CreateCrew.OnServerEvent:Connect(createcrew)
0
Update: found a piece of code that may help, ill try it in a bit pengalu200 65 — 5y

1 answer

Log in to vote
1
Answered by
AspectW 431 Moderation Voter
5 years ago
Edited 4 years ago

Loop through the Teams service:

for i,v in pairs(game:GetService("Teams"):GetChildren()) do
    if v.TeamColor == Color then --if it's the same color then
    -- your code here
    end
end
0
Thanks! pengalu200 65 — 5y
Ad

Answer this question