What does ToObjectSpace() and ToWorldSpace() do?

The wiki has a very limited explanation on this topic, I don’t think its even a sentence, so i was wondering if any of you knew what these functions were, and how they work?


:ToObjectSpace() converts a CFrame relative to the world relative to a specific part.
For example let’s say object A is at 0, 10, 0 and object B is at 0, 20, 0. If we ran: print(objectA.CFrame:ToObjectSpace(objectB.CFrame) it would print 0,10,0 as object A is 10 studs above object B. It’s treating object B’s CFrame as the center of the world.

:ToWorldSpace() does exactly the opposite and returns a CFrame relative to the center of the world (0, 0, 0). So if object C’s CFrame is 0, 10, 0 away from 0, 0, 0, it would return 0, 10, 0.


Both of those methods convert a CFrame to a specific space. World relates to the origin (0, 0, 0) axis (like when you insert parts via Roblox Studio), while object space sets it relative to the object (hence “object space”).

Using them is as simple as calling the method on a CFrame, like Part.CFrame:ToObjectSpace(). The real pain comes from operations like additives, if you aren’t well versed in CFrames (I, for one, am not at all).

Typically, everything defaults to world space unless otherwise determined by a property or scripted feature.