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

How to detect how many people are standing on a part?

I want to make a surface gui that tell how many people are touching a part at the moment

2 comments

0

You can create a Region3, Region3 gets all theparts in the region. By using FindPartsInRegion3WithWhiteList, it'd get all parts that are in the Whitelist, you could use this to detect the number of players in the Region.

0

use a touched event, a debounce, a disconnected event and a variable from the server

1 answer

well part objects have the Touched and TouchEnded events. you could use this in your favor, like this:

part = workspace.Part
people_standing = 0 -- amount of people on the part

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then -- if a player has touched the part then
		people_standing = people_standing + 1
	end
end)

part.TouchEnded:Connect(function(hit)
	if hit.Parent.FindFirstChild("Humanoid") then -- if a player has quit touching the part then
		people_standing = people_standing - 1
	end
end)

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