Won't create a new team?

So basically Im trying to make a team GUI where if you’re in a certain group and click lets say the “National Guard” button it will create a new team. I don’t want to have to manually input teams because it looks sloppy since they appear even when players are not in the team.

So how would I make this function in fe and make the team disappear if no one is in it It is located here: image

Here is my code so far:

      >   local but = script.Parent:WaitForChild("TextButton")
     but.MouseButton1Down:Connect(function()
     	local test = Instance.new("Team")
     	test.TeamColor = ("Really red")
      	test.Parent = game.Teams
      end)

First off, this needs to be in a LocalScript, since you are handling user interface…

Second off, if you need to change a team via a GUI, you need remote events.

Third, TeamColor points to a BrickColor, not a string. It needs to be BrickColor.new("Really red").

2 Likes

I tried it in a localscript. And I tried brickcolor. Nothing worked but I’ll try the remoteevents

Go with what incapaxx stated. You should never use a Script to use any sort of interface events. However, this would work if you were to implement what incapaxx had said as well as taking advantage of RemoteEvents for these changes to replicate throughout the server.

Also, please note. When you use a RemoteEvent, you always want to add “Player” as the first parameter. I see this mistake a lot and the first parameter on a RemoteEvent is always the player whose fired the remote. I’ve listed an example on how to use RemoteEvents below.

local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Parent = game:GetService("ReplicatedStorage")

RemoteEvent.OnServerEvent:Connect(function(Player, YourOtherParam)
print(Player.Name)
end)

Also, to answer your second reply. This is absolutely the correct section to ask these questions and receive the help you need.

3 Likes

Thank you very much. This helped a lot.

1 Like

No problem. :slight_smile: If you have anymore questions, please feel free to ask. And @incapaxx thanks for clarifying, I was confused on why he said it was the wrong section.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.