Custom part to part collision

Hello everyone! I need to make a custom system which determines if two parts are colliding they can be rotated in any way ( ! ). I tried doing it, but to no avail. Though, I managed to write a function that finds out if a vector3 position is inside a Part, except the part is separated into cframe and size.

local function IsPointInOrientedBox(point, cf, size)
    local vecOffset = cf:PointToObjectSpace(point)

    local vecX = vecOffset.X
    local vecY = vecOffset.Y
    local vecZ = vecOffset.Z

    local halfX = size.X/2
    local halfY = size.Y/2
    local halfZ = size.Z/2

    local inX = (vecX >= -halfX and 1 or 0) + (vecX <= halfX and 1 or 0)
    local inY = (vecY >= -halfY and 1 or 0) + (vecY <= halfY and 1 or 0) 
    local inZ = (vecZ >= -halfZ and 1 or 0) + (vecZ <= halfZ and 1 or 0) 

    local collSum = inX + inY + inZ

    return collSum == 6 and true or false
end

Could any of you help me write a function just like the one above, except for cframe and size instead of just a point? Any help is appreciated, thanks in advance!

When dealing with rotated objects its a bit thinicky. You need to treat it as one of the transformation, shearing, scaling, rotating operations in a sense. All of those I mentioned can convert coordinates into a locally simulated space in a sense. So if you can convert your rotated coordinates into aabb coordinates, that is aligned to an axis. From there it just becomes a measure of seeing where it intersected. Then transforming those intersected coordinates back to the locally simulated space by the whatever matrix we used to change it to match the world coordinates.

I know. Except I can’t just convert one part into the others part local space and check for collisions, since both of them are rotated.

No you can, you need to both rotate them to world space coordinates

No, because the entire point is to look for collisions on rotated parts