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 get all players of a certain team thats also in a certain part?

I was wondering if it is possible to get all players of a certain team thats also touching a part or in a region.

1 answer

✓ Accepted answer

I doubt this will work, I don't know if you can but a for in pairs inside a function, just some way to run a for in pairs loop somewhere, if you get what I mean. But, here's Getting the player's teams, but it's not activated by a touch.

If this doesn't work, DM me on discord, A_Mp5#5847

local StepOne = game:GetService("Players")
--If you're making this a cuntion, but the start HERE, Not UP THERE or DOWN THERE.
local Example = StepOne:GetChildren()
for i, plyrs in pairs (Example) do
	local StepThree = StepOne:FindFirstChild(plyrs.Name) -- Otherwise remove name if this 	doesn't work
	print(StepThree)
	--Then,you can put a if StepThree.Team == "team" then , or something.
	
end
--If you're making a function, put the end HERE.

Here's another way to do it, if you want, but this one may be a bit more buggy.

local StepOne = game:GetService("Players")
--If you're making this a cuntion, but the start HERE, Not UP THERE or DOWN THERE.
local Example = StepOne:GetChildren()
for i, plyrs in pairs (Example) do
	local StepThree = game:GetService("Players"):GetPlayerFromCharacter(plyrs) -- Otherwise remove name if this 	doesn't work
	print(StepThree)
	--Then,you can put a if StepThree.Team == "team" then, or something.
	
end
--If you're making a function, put the end HERE.

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