Object CFrame problem

Hello, I am making placement system with plots for my game where placed objects can be loaded on other plots.

The issue is that I don’t know how to set objects CFrame relative to other plots.

For example:
There are 3 objects on plot_1 and their CFrames are saved when player leaves.

When player joins then the CFrames of these objects are loaded and player can choose the plot. When player choosed plot_2 not plot_1 then the objects doesn’t spawn on plot_2 but on plot_1 but they should spawn on plot_2 (choosed plot).

Where objects should be when player chooses plot_4:


Where are they: (despite this that player choosed plot_4 not plot_1)

And there is my question: How to set these objects CFrames relative to other plots? When player places 3 objects on plot_1 and then load these objects on plot_2 then the objects will be spawned on top of plot_2 not plot_1. How to change their CFrames to be on top of plot_2 not plot_1?

I tried using :ToWorldSpace() and :ToObjectSpace() but I don’t understand them too much. :slightly_frowning_face:

You need to use PointToWorldSpace / PointToObjectSpace with the plot tile’s CFrame as the leftmost argument (before the colon : ). Point to object space returns a point in the space of the CFrame provided. For a part CFrame this means the result will be coordinates relative to the part’s center and with X Y Z components specified in (see note) that parts Forward / Right / Up vectors. PointToWorldSpace reverses this transfomation. Probably what you want is to save the furniture locations in “ObjectSpace” (Relative to the plot) and then when you set their positions for placement in the world, convert back to World Space using PointToWorldSpace, since all positions of parts are in World Space.

The number one troubleshooting tip for using spaces like this is that all vector operations must be done in the same space, or the result is not meaningful (wrong). For example you can multiply a world space vector by another world space vector, but not a world space vector by an object space vector.

note: All vector spaces are defined by (for 3D spaces) 3 “basis” vectors. World space is special in that its assumed to be the “master” space in which other spaces are defined. For example, a rotated part will have some specific Right Forward and Up direction (this is how the CFrame is defined), if you took another vector and multiplied each component by these three directions and added them up, you will have converted the original vector into the same space those Right Forward and Up were defined in (World Space). In that way, you can say your original vector was in the “Local Space” of the part.

1 Like

Thanks for the explanation! Now it’s working! :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.