I want to make a surface gui that tell how many people are touching a part at the moment
COMMUNITY QUESTION
How to detect how many people are standing on a part?
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.

2 comments
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.
use a touched event, a debounce, a disconnected event and a variable from the server