GetPartsInPart() Problem

I trying to make a Totally Accurate Battle Simulator type of game and I am making the adding-fighter feature and The GetPartsInPart is very inconsistent:

This is some of the code that I suspect is the issue.

CurrentBox:PivotTo(CFrame.new(SendRay().Position)) -- returns raycast
			
			local filterObjects = {CurrentBox}
			local maxObjectsAllowed = math.huge
			local params = OverlapParams.new(filterObjects, Enum.RaycastFilterType.Include, maxObjectsAllowed, "Default")
			local objectsInSpace = workspace:GetPartsInPart(RPH.RedRegion, params)
			
			for i, v in pairs(objectsInSpace) do
				if v == CurrentBox then
					PlacingObject = true
					CurrentBox.BrickColor = BrickColor.new("Lime green")
				else
					PlacingObject = false
					CurrentBox.BrickColor = BrickColor.new("Really red")
				end
			end
end)

Also, the script is on the client side.

Any help is appriciated :slight_smile:.

try using a raycast from above the tower and check if it hits the redregion

1 Like

I tried it and it is still the same thing:

OverlapParams.new doesn’t have parameters so you have to set its properties
like this

local params = OverlapParams.new()
params.FilterDescendantsInstances = filterObjects
params.FilterType = Enum.RaycastFilterType.Include
1 Like

Thank you, I forgot about that.

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