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.

01function createcrew(player,color)
02    print("buy")
03    if player.leaderstats.Doubloons.Value >= 5 then
04 
05        print("money")
06        player.leaderstats.Doubloons.Value = player.leaderstats.Doubloons.Value - 5
07        local team = Instance.new("Team")
08        team.AutoAssignable = false
09        team.TeamColor = color
10        team.Parent = game.Teams
11        team.Name = player.Name.."'s Crew"
12        player.Team = team
13        player.Neutral = false
14        local owner = Instance.new("StringValue")
15        owner.Name = "Owner"
View all 25 lines...
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 5 years ago

Loop through the Teams service:

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

Answer this question