Help understanding cf:ToObjectSpace() cf:ToWorldSpace()

I know I already made posts about it, I know there’s other posts about it, but none help me understand it, I already know what’s Object space and World space but

I need to know what cf:ToObjectSpace() and cf:ToWorldSpace() do
I don’t understand it /:

1 Like

CF1:ToObjectSpace(CF2) is equivalent to CF1:inverse() * CF2, and this function gets the relative offset of CF2 in relation to CF1. If CF1 is at 10, 0, 10 and CF2 is at 20, 10, 30, then CF1:ToObjectSpace(CF2) will return 10, 10, 20, which is CF2’s CFrame in relation to / from CF1 in object space. You can multiply the relative offset to CF1 to get back at the CFrame of CF2 in world space:

local offset = CF1:ToObjectSpace(CF2)
Part.CFrame = CF1 * offset

CF1:ToWorldSpace(CF2) is equivalent to CF1 * CF2 which converts a relative offset in object space, which is CF2, to world space. This function treats CF1 as the origin and basically “adds” CF2 onto it. For the above function, instead of Part.CFrame = CF1 * offset, you can have Part.CFrame = CF1:ToWorldSpace(CF2), since they’re basically the same

4 Likes