Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get all players in a certain area?

Long story short, I'm creating a minigame type game. I have doors that open up then players walk in. Whats the best way to grab all the players in an area?

3 comments

0

If you mean in the same place but a certain area, then this will use Region3 and all that stuff. Can't really explain it much, sorry!

0

if I helped you out please accept my answer. Otherwise comment how I can help you better.

2 answers

To answer your question, all you need to do is grab all of the player's HumanoidRootPart to your position that you want:

function teleportAllPlayers(partToTeleportTo)
	for _,i in pairs(game.Players:GetChildren()) do
		i.Character.HumanoidRootPart.CFrame = CFrame.new(partToTeleportTo.Position)
	end
end

Usage:

teleportAllPlayers(game.Workspace.DemoPart)

1 comment

0

Not trying to teleport them. They walk in the playing area themselves. I just need to find the players that walked in so the script knows who's playing and who's not playing.

I am assuming that you are trying to teleport all of the players in the room. To do this all you need is a Region3. Make it the size of your room. Then when it is time to teleport the players in the room loop through all the players in the game and use an if statement to check and see if they are inside the Region3. You provided no code so I will write none for you. If you have any additional questions just post them in the comments below my question. I hope this helps and have a great day scripting!

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