How to add multiple things in a regions ignore list

I’m trying to make a door detect the player if the player is inside a region. The problem is that I can’t figure out how to add multiple parts in the regions ignore list. When I add a table, an error pops up saying

Unable to cast value to Object

Here’s what I’m working with:

local ignoreList = {
	-- Ignores everything in the model
	doorModel,
	doorPart,
	doorHitbox,
	doorModel.Wall1,
	doorModel.Wall2
}

local pos1 = doorHitbox.Position - (doorHitbox.Size / 2)
local pos2 = doorHitbox.Position + (doorHitbox.Size / 2)

local doorRegion = Region3.new(pos1, pos2)

-- Here is the problem 
local partsinDoorRegion = game.Workspace:FindPartsInRegion3(doorRegion, ignoreList, 1000)
	
	for i, parts in partsinDoorRegion do
		if parts.Parent:FindFirstChild("Humanoid") then
			openDoor()
		else
			closeDoor()
		end
	end

Region3 functions are outdated and deprecated. Use spatial query functions such as workspace:GetPartBoundsInBox() or workspace:GetPartsInPart() instead. These newer functions use OverlapParams which are very similar to RaycastParams.

1 Like

Ok it works a little bit but now that door only opens halfway, and when I exit the door opens fully and then closes.


Ok Thanks! I Made it work using GetPartBoundsInBox()

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