Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

Update: found a piece of code that may help, ill try it in a bit

1 answer

✓ Accepted answer

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

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.