How to get all players of a certain team in a specific zone

Sorry I’m bad at spelling titles :,)
So I got a security screen, which is suppose to update everytime a player of a certain touches the “danger” zone, like, we have 3 soldier, 3 prisonners, and 2 civilians, it’ll put on the screen :
Soldier : 3
Prisonners : 3
Civilian : 3

How can I do a thing like this (don’t require full script, just a thing to get the players and add a value)

1 Like

Uhhh, you could probably use Region3 and find that player in “Players” and identify if they are on a team with some if statements. table.add() them if they are. Not exactly sure if this is really what you are asking for here but yeah.

Like basicly take all player in a zone, turn it into a value, and the screen automaticly take the value and show it

If I am misunderstanding your question please correct me, but do you mean display the amount of players in a team onto a screen?

You can use Region3 to check which are they are in, here is an article if you need help understanding it. To sum it up it basically creates a box shaped region from the bottom left point and the top right point which you can then use to see if any players are touching it.

Next you will want to add these players to a table or team in the team folder, depending on how you are doing it. If table you can use table.insert() and table.remove() to add or remove players from a team and you can set a player’s team if you are doing it via team folder. Then you can get the number of that team by using GetChildren() and by putting a # in front of the definition or statement and set it to your screen. Hope this helps!

2 Likes

I’m not very familiar with Reg3 bt Imma try, thanks
Just don’t really understand this :

Region3.new(Vector3.new(2, 3, 4), Vector3.new(8, 6, 5))

And how to use it in a function

To help you understand the first parameter would be the bottom left point Vector3.new(2, 3, 4) and the second parameter would be the top right point Vector3.new(8, 6, 5). What Region3 does is takes these two points and creates a box like shape similar to a normal part and uses it as a region. It can then be used to determine if someone is inside of it or not, it can be really useful in some cases.

Oh I see,
Cuz I saw something like
Region3.Size =
So i didn’t really understood what was its utility

To get the players in a team you would use GetPlayers on the team.