Alright well getting the sides might be overdoing it so instead we can use directional vectors!
So if you want to place a part in the front, we can just take the reference part and use the LookVector
(what way the part is facing) and multiply it by some number (like 2 or 3) and it’ll be in front!
Alright now what about if we wanna place a part in the front?
Well, we don’t have a “behind vector” property so we can just use -LookVector
which is the same thing basically.
If our part has a LookVector of (0, 0, -1)
(facing forward relative to the origin)
then our “behind vector” would be (0, 0, 1)
aka the opposite direction!
Hopefully this has been so far, we can also work with the RightVector
property to place a part on the right side.
If we want the left, we can just negate the RightVector
property.
And there is also an UpVector
property. Hopefully you can now figure out how to get the down vector
One last thing…
You have to add the result of the directional vector to the reference part’s position.
“Why?”
Well, just changing the part’s position to the LookVector or whatever (0, 0, -1 for example) would just place it in the wrong place. By adding the value to the position, we’re basically moving a little in that direction if that makes sense.
If our part is at
(10, 10, 10)
and we wanna move forward (assuming the part is facing forward relative to the origin)…
Then our new position would be
(10, 10, 9)
since forwards would be (0, 0, -1)
!
In code, you could basically write something like this I guess:
-- example ofc
local part = …
local Newpart = …
local place_to_put =
Vector3.new(
part.Position
+
part.CFrame.LookVector * 3
)
Newpart.Position = place_to_put
Lmk if there’s anything confusing / mistakes so I can fix my post!