So I’ve been working on a model placement system recently. But I am having some trouble triyng to get collision detection to work.
It seems my current method for collision detection isn’t reliable. As shown in this video:
It’s kind of a hit or miss. Which is not good.
So I now need a new way of checking collisions when building, but I can’t seem to find anything online to help me with my case.
So some help would be greatly appreciated. Thank you!
local function GetTouchingParts(PrimaryPart)
local connection = PrimaryPart.Touched:Connect(function() end) -- This allows for parts with CanCollide false to work with GetTouchingParts()
local results = PrimaryPart:GetTouchingParts()
local FilteredResults = {}
for i, Part in ipairs(results) do
if Part.Parent and Part.Parent ~= PreviewModel and Part.Transparency < 1 then -- Make sure that the part(s) we are hitting is not in our model
FilteredResults[i] = Part
end
end
connection:Disconnect() -- We no longer need this connection.
return FilteredResults
end