Team setup dynamically

In my gamemode I’m trying to make it so that players can set up teams through a teams panel. I want to use the premade team stuff so team chat and such works. Issue I’m having is getting the team on both the server and the clients. When I just do team.SetUp(…) in the shared.lua it works. Issue is when I run the team.SetUp in a net.Receive it only creates it on the server and the client doesnt get it. So to fix this I was going and netting everytime a team changes, but this would involve every time the score changes id be sending info to the client. It seems a bit ridiculous. How can I create this team so both get the same list?


net.Receive("CreateNewTeam", function(len, pl) 
	print("hi")
	local TeamInfo = net.ReadTable()
	local Teams = {}
	local TeamID = 0
	for k,v in pairs(team.GetAllTeams()) do
		if k!=0 && k!=1001 && k!=1002 then Teams[k] = v end
	end
	for k,v in pairs(Teams) do
		if team.NumPlayers(k) < 1 then
			TeamID = k
		end
	end
	if TeamID==0 then TeamID = table.maxn(Teams)+1 end
	team.SetUp(TeamID, TeamInfo[1], TeamInfo[2], TeamInfo[3])
	pl:SetTeam(TeamID)
	pl:PrintMessage(HUD_PRINTTALK, "You've created the team "..TeamInfo[1]..".")
	BroadcastTeamList()
end)


	TeamFinalizeButton.DoClick = function()
		if TeamCreateName:GetValue()!=nil && TeamCreateName:GetValue()!="" then
			if TeamLockedMenu:GetValue()=="Yes" then joinable = 0 else joinable = 1 end
			net.Start("CreateNewTeam")
			net.WriteTable({TeamCreateName:GetValue(), TeamColor:GetColor(),joinable})
			net.SendToServer()
			TeamCreatePanel:Remove()
		else
			TeamName:SetColor(Color(225,0,0,255))
			LocalPlayer():PrintMessage(HUD_PRINTTALK, "Team name needed.")
		end
	end

I’m just getting frustrated at this so any help would be appreciated. I figure it has to be possible. Thanks.

I know ULX allows you to do something like this in one of their modules so you may want to have a look at that