Detect How much Players standing in the path/Part

Hello, I made Horror game and Elevator, and I need to detect How much Players standing in the part(with Number) I need script to detect How much Players standing in the part that really Help for me

is this how u do it?

local Players_In_Area = 0
local plrs = {}

script.Parent.Touched:Connect(function(plr)
	local char = plr:FindFirstAncestorWhichIsA("Model")
	
	if not plrs[char.Name] then
		if game.Players:FindFirstChild(char.Name) then
			plrs[char.Name] = 0
			Players_In_Area += 1
		end
	end
end)

script.Parent.TouchEnded:Connect(function(plr)
	local char = plr:FindFirstAncestorWhichIsA("Model")
	
	if plrs[char.Name] then
		if game.Players:FindFirstChild(char.Name) then
			plrs[char.Name] = nil
			Players_In_Area -= 1
		end
	end
end)

I can’t guarantee that, did you test it on roblox?

If you find a post on the devforum like you did, I would recommend testing it before trying it out here!

I’ve tried it but I don’t know how to test if it’ll work

What do you mean by this?

Its alright ill just try to find another way

It’s okay, just I don’t think I understand by what you mean.

Okay, (random text….)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.