So i got a dragging system it's a localscript i put it on player starterpack, it uses setprimarypartcframe to move the model, the problem is the model can be placed to another models it's like its cancollide even tho the parts itself is not, so i was told to use region3 so i did but there's problem..
This is only part of my dragging script on starterpack, which when a player released the button assuming the player is dragging the cloned model it's supposed to checked if there is parts on the area, if there is none it'll print no parts and if there is then it'll print "parts".
THE PROBLEM
it prints parts so it detects but whenever i move it to area where there is no parts it says '23:40:52.528 - Players.Player1.Backpack.mouseTargeting:62: attempt to index local 'd' (a nil value)'
mouse.Button1Up:connect(function()
while wait() do
local ignorep = mouse.Target.Parent
local d = mouse.TargetFilter
local pos = d.Position
local size = d.Size/2
local reg = Region3.new(pos - size, pos + size)
local ignore = {workspace.Baseplate,d,ignorep}
local n = workspace:FindPartsInRegion3WithIgnoreList(reg,ignore,100)
if #n <= 0 then
print("no parts")
mouse.TargetFilter = nil
_G.down = false
_G.target = nil
else
print("parts")
end
end

1 comment
Before line 5, check if 'd' is nil.