# CFrame:ToWorldSpace() and CFrame:ToObjectSpace(), What is that?

I already have some post about “Relative to Object/Part” or still “Relative to the World”, but I don’t understand it. The only thing I know is that they have something to do with the functions `CFrame:ToWorldSpace()` and `CFrame:ToObjectSpace()`. I already read about CFrame in the article, but didn’t understand it. Can anyone help me?

2 Likes

Think of it like this:

Object Space: The xyz axis is rotated like the part shown:

World Space: The xyz axis is to the worlds axis:
(
Sorry for my bad image editing skills)

## CFrame:toWorldSpace(cf)

This method converts a cframe in object space to a cframe in world space . In other words it takes `cf` (which is relative to `CFrame` ) and returns a result that is relative to the origin. For example, if I have a cframe called `cf1` which is defined to be `CFrame.new(0 , 10 , 0)` and I have another cframe relative to `cf1` called `cf2` which is `CFrame.new(1 , 0 , 0)` , `cf1:toWorldSpace(cf2)` will return a cframe in world space that is relative to the origin/identity cframe .

## CFrame:toObjectSpace(cf)

This method does the exact opposite. Given a CFrame (let’s call it `cf1` ), and an input CFrame (call it `c2` ), it will return a result representing the cframe `cf2` is in relative to `cf1` . For example, if an input `CFrame` defined `CFrame.new(5 , 1 , 3)` is given, `CFrame.new(1 , 1 1):toObjectSpace(cf)` will return `CFrame.new(4 , 0 , 2)` because that is the `CFrame` the input is in relative to `CFrame.new(1 , 1 , 1)`

26 Likes

A question, why do you have to use two CF for these two functions?

2 Likes

You don’t. you literally type `CFrame:ToWorld/ObjSpace` not `CFrame.new(x,y,z):ToWorld/ObjSpace`.

Also sorry for the bump

1 Like