Getting relative position

Hello, I am in a predicament and I have no idea what I am doing.

Basically I want to get an objects’s relative position to a part in object space

image

In this example the blue part is 2 studs down the red part’s X axis

So if you would do Bluepart.CFrame * Redpart.CFrame:Inverse() it would print

print((Bluepart.CFrame * Redpart.CFrame:Inverse()).Position)

it would print (-2,0,0)

But if I want to rotate this red part 90 degrees

image

and do the same thing, it would print (0,0,-2) because it’s X axis is relative to the world

How would I make it print it’s position relative to the red part like (-2,0,0)?

1 Like

this might help

read the Relative Position

3 Likes

I just figured it out, its Redpart.CFrame:ToObjectSpace(Bluepart.CFrame).

4 Likes