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)