Team Select + Team Spawns

Hello! Welcome to my first devforum tutorial!

Today I wanted to learn people how to make a Team Select GUI + Team Spawns!

Step 1
Activate the Team Service.
Go into the “Model” Tab and go over to “Advanced” and choose the bottom left icon, with the blue and red things.
Screenshot 2020-09-26 at 17.35.36
Click the button and this screen will open.
Screenshot 2020-09-26 at 17.38.05
Click “Teams” and insert it! We will need this further into the tutorial!
Step 2
Now, you will have to add a ScreenGui, with a frame.
Screenshot 2020-09-26 at 17.33.06
Step 3
Add in as many TextButtons as the teams you want. All those buttons will need a LocalScript inside of it.
Screenshot 2020-09-26 at 17.42.17
Your GUI now should look like this.
Step 4
This is really important! Add in an “ObjectValue” in the TextButtons. We’re not going to do anything with this yet. Call these Values “Team”.
Step 5
Add teams into the “Teams” folder.
The first Team you’ll add will be called “Choosing Team”. This will be for the users who just joined and still need to choose what team they want to be on. Keep all settings, don’t change anything. Now it’s time to add your own teams!
I will add two simple teams called “Noobs” and “Pros”.
Step 6
Change the text of your TextButtons to the teams you have. Now we’re going to do something with the values we have inserted in Step 4. You want to name both of these values to the name of the team, which should be in your textbutton. Next, you will have to CLICK the field so this appears. Make sure this appears.


Now, you need to know what teams ObjectValue you’ve chosen by looking at the TextButton. For example, I chose the value of my “Pros” team. Now you want to make sure you still have the value clicked, and you want to open the “Teams” folder and then click the team which you chose the value of. For example, I chose Pros, now I need to click on the Pros team in my team folder.

You should now have this. Do the same for the other teams.
Step 7
Time to script!

local team = script.Parent.Team

local frame = script.Parent.Parent

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()

frame.Visible = false

player.Team = team.Value

end)

No need to change anything, just put this in all localscripts in your GUI.
Last step, 8
Now, we’re going to make the team spawns. Insert two SpawnPoints into your game.


Open these settings. Now, you want to give the Teams in the Teams folder two different colours, and change TeamColor in these settings to one of the Teams its colors. Now, that team will spawn at that SpawnLocation. Do this with both spawn points.

Now, the player will spawn at the right spawn after selecting their team! If you have any questions, don’t hesitate to ask!

Thanks for reading my tutorial! :slight_smile:

12 Likes

Nice tutorial.

Use .Activated event, it’s better. and connect is deprecated use Connect instead

Change the GUI script from
local team = script.Parent.Team

local frame = script.Parent.Parent

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()

frame.Visible = false

player.Team = team.Value

end)

To
local team = script.Parent.Team

local frame = script.Parent.Parent

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()

frame:Destroy()

player.Team = team.Value

end)

5 Likes

Why should I use .Activated? What does this event do?

I’ve heard it’s better than mousebutton events and it looks cleaner too. Though I dont have any proof of it being better, I will try to research otherwise yeah mousebutton events should work too.

Alright, thanks for your feedback. Will do some things with it later on :smiley:

1 Like

I’ve heard it has support for controllers. I’m not sure if normal buttons do though.

This tutorial is a little too specific and non-utility for most developers. That being said, it also has some critical flaws. When writing tutorials, make sure to proofread your material and ensure that what you’re doing works.

The largest point here is that you’re missing a RemoteEvent. The player’s team won’t actually change because you’re missing that remote, it will only change on the current client’s perspective, so that is something you need to include. When the client clicks a button, it should fire a remote to the server to change the team.

As for coding the actual buttons, you should avoid using multiple LocalScripts for this. You can use a single LocalScript that goes over all the buttons and connects a click event where the name of the team clicked is fired as an argument in a RemoteEvent to the server. The server can then decide what team the player requested to change to and then accordingly change their team.

The ObjectValues are not needed.

3 Likes

I’m sorry, i will try to improve next time

@colbert2677 Can I keep this tutorial up tho?

1 Like