Hey Chilling_Legacy,
It may help to translate that vector by another vector based on the face of the block you're pointing at. Observe:
local BlockSize = 4;
local Directions = {
Enum.NormalId.Right = Vector3.new(0, 0, BlockSize);
Enum.NormalId.Top = Vector3.new(0, BlockSize, 0);
Enum.NormalId.Back = Vector3.new(-BlockSize, 0, 0);
Enum.NormalId.Left = Vector3.new(0, 0, -BlockSize);
Enum.NormalId.Bottom = Vector3.new(0, -BlockSize, 0);
Enum.NormalId.Front = Vector3.new(BlockSize, 0, 0);
};
local relativePos = mouse.Target.Position + Directions[mouse.TargetSurface];
selectedBlock:MoveTo(relativePos);
I hope this helps. I may have assigned the wrong values to the respective Directions, so if the block spawns on the wrong side, that is why. All you need to do to fix that is tweak the Directions table accordingly.
Now, this approach is a little specialized in that it only offsets the current block by BlockSize. It may help to use your original approach as well as my approach alternatively based upon the nature of the current target.
For example, if you tried placing a block on the baseplate, instead of placing at your cursor, the block would be placed at the center of the baseplate, because the block is being positioned at the position of the baseplate plus 0, 4, 0. Exactly how you rectify this is something you might need to solve yourself.
I hope this helps. Best of luck with your game, Chilling_Legacy. Have a nice day!
All the best,
tkcmdr
1 comment
Do you mean the block is being created on top rather than on the side?