FindPartOnRayWithIgnoreList() not really working

long story short, im creating a placement system and i need to detect if the hitbox is inside the allowed building area. so i have added the build areas to a blacklist table, so the ray that gets the mouse position wont detect it, but its not working. im not really good at explaining things so here are some pics

the big green part is the build area which is supposed to be on the ignore list and the red part is the part i am placing


image

if you want i can post the script
edit: so here is the script.

local module = {}
local RR3 = require(game.ReplicatedStorage.RotatedRegion3)

module.place = function(plr,item)
	local canPlace = false
	local itemTransparent = item:Clone()
	local function refreshcolor()
		if canPlace == true then
			for i,v in pairs(itemTransparent.Parts:GetChildren()) do
				if v.Name == "Hitbox" then
					v.Transparency = 0.5
					v.Color = Color3.fromRGB(0, 214, 0)
				else
					v.Transparency = 0.5
				end
			end
		else
			for i,v in pairs(itemTransparent.Parts:GetChildren()) do
				if v.Name == "Hitbox" then
					v.Transparency = 0.5
					v.Color = Color3.fromRGB(200, 0, 0)
				else
					v.Transparency = 0.5
				end
			end
		end
	end
	refreshcolor()
	local blacklist = {}
	local plot
	for i,v in pairs(game.Workspace.Plots:GetChildren()) do
		if v.Owner.Value == plr.Name then
			plot = v
			for i,b in pairs(v.BaseParts:GetChildren()) do
				b.Grid.Transparency = 0
			end
		end
	end
	for i,v in pairs(itemTransparent.Parts:GetChildren()) do
		table.insert(blacklist,v)
	end
	for i,v in pairs(plot.BuildAreas:GetChildren()) do
		table.insert(blacklist,v)
	end
	local mouse = plr:GetMouse()
	local hitbox = itemTransparent.Parts.PrimaryPart
	local function snapToGrid(vector3,middle,folder,posx,posz)
		local x = math.floor(vector3.X+0.5)
		local y = math.floor(vector3.Y+0.5)
		local z = math.floor(vector3.Z+0.5)
		if itemTransparent.Parts.PrimaryPart.Size.X % 2 ~= 0 then
			if posx > x then
				x += 0.5
			else
				x -= 0.5
			end
		end
		if itemTransparent.Parts.PrimaryPart.Size.Z % 2 ~= 0 then
			if posz > z then
				z += 0.5
			else
				z -= 0.5
			end
		end
		folder.Parts:MoveTo(middle+Vector3.new(-x,y + folder.Parts.PrimaryPart.Size.Y/2,-z))
		local rogi = {
			{1, 1, -1},  --v1 - top front right
			{1, -1, -1}, --v2 - bottom front right
			{-1, -1, -1},--v3 - bottom front left
			{-1, 1, -1}, --v4 - top front left

			{1, 1, 1},  --v5 - top back right
			{1, -1, 1}, --v6 - bottom back right
			{-1, -1, 1},--v7 - bottom back left
			{-1, 1, 1}  --v8 - top back left
		}
		local buildareas = plot.BuildAreas:GetChildren()
		local boolTable = {}
		for i,v in pairs(rogi) do
			local CornerPos = (hitbox.CFrame * CFrame.new(hitbox.Size.X/2 * v[1], hitbox.Size.Y/2 * v[2], hitbox.Size.Z/2 * v[3]))
			local region = RR3.new(CornerPos,Vector3.new(0.05,0.05,0.05))
			local partsfound = region:FindPartsInRegion3WithWhiteList(buildareas)
			if #partsfound == 0 then
				table.insert(boolTable,false)
			else
				table.insert(boolTable,true)
			end
		end
		if not table.find(boolTable,false) then
			canPlace = true
		else
			canPlace = false
		end
		refreshcolor()
	end
	local RS = game:GetService("RunService")
	local UIS = game:GetService("UserInputService")
	itemTransparent.Parent = workspace.Placing
	RS.RenderStepped:connect(function()
		local ray = Ray.new(mouse.UnitRay.Origin,mouse.UnitRay.Direction*1000)
		local hit, mousepos = game.Workspace:FindPartOnRayWithIgnoreList(ray, blacklist)
		local pos = plot.BaseParts.BasePart1.Position - mousepos
		if hit then
			snapToGrid(pos,plot.BaseParts.BasePart1.Position,itemTransparent,mousepos.X,mousepos.Z)
		end
		wait()
	end)
	UIS.Changed:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
			if canPlace == true then
				
			end
		end
	end)
end

return module

this is the part of the script where it gets the position

RS.RenderStepped:connect(function()
		local ray = Ray.new(mouse.UnitRay.Origin,mouse.UnitRay.Direction*1000)
		local hit, mousepos = game.Workspace:FindPartOnRayWithIgnoreList(ray, blacklist)
		local pos = plot.BaseParts.BasePart1.Position - mousepos
		if hit then
			snapToGrid(pos,plot.BaseParts.BasePart1.Position,itemTransparent,mousepos.X,mousepos.Z)
		end
		wait()
	end)
2 Likes

Its probably for the best if you show us the script;

2 Likes

okay, i have edited the post and added the script

2 Likes

Since you’re doing plot selection, wouldn’t it be better to have each plot as allowed? And instead use a Whitelist?

2 Likes

yeah thats what i did first but there is a problem, or even two problems.

  1. if you select the edge of the base half of the hitbox will go past the base
  2. i want to make it so you can place on other structures aswell
1 Like

FindPartOnRayWithIgnoreList is deprecated, look into WorldRoot:Raycast()

uhhh i have tried that before andd i have had lots of problems but ima try again i guess…

1 Like

Then add the buildings in the plot to the whitelist.

1 Like

and then the second problem appears

1 Like