I'm using Region3 for this this door that I'm creating. The door opens perfectly fine when the player is inside the region. When it comes to closing it, I'm having a lot of trouble. How would I go about seeing if there are no players in the region?
Here's a general gist of the code opening the door
local region = Region3.new(pos1, pos2)
while true do
wait(1)
local partsInRegion = game.Workspace:FindPartsInRegion3(region, nil, math.huge)
local playersFound = {}
for _, part in pairs(partsInRegion) do
if part.Parent:FindFirstChild("Humanoid") ~= nil then
print("PLAYER!")
playersFound[part.Parent.Name] = part.Parent
end
end
for plrName, char in pairs(playersFound) do
if char then
if opened == false then
Door1Open:Play()
wait(openWait)
opened = true
end
end
end
end
