I’ve been trying to get this function to work for a bit now. I looked at advice for getting adjacent collision detections. I don’t want to have a region3 because I’ve heard they can be computationally expensive, so I’ve been trying the slightly larger part method of making a hitbox, but for some reason these boxes just aren’t detecting anything. The part I want to detect does have CanCollide off but has CanTouch on.
I’ve been using comically large sizes for testing purposes and it does not seem to appear at all.
-- Create a function that creates a slightly larger part that can detect adjacent parts.
local function get_touching_from_hitbox(part, size)
local hitbox = Instance.new("Part")
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.CanTouch = true
hitbox.Size = Vector3.new(size, size, size)
hitbox.CFrame = part.CFrame
hitbox.Transparency = 0
hitbox.BrickColor = BrickColor.Red()
local connection = hitbox.Touched:Connect(function() end)
local results = hitbox:GetTouchingParts()
connection:Disconnect()
if #results == 0 then
print('Bruh')
end
hitbox:Destroy()
return results
end