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)
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