This is sort of hard to explain, let's say i want a part to teleport to the arm of the player, but on It's side, if i set the part's position to the player's arm position, the part will be inside the arm
Of course i could move it a little to the side, that way it would be on the surface of the arm, yet this is inconsistent because if the character is bigger, the arm would be bigger, and the part would stop to be on the surface of the arm again.
Is there something i can do to detect the surface position of a part?
I hope i explained myself correctly, i wish i could provide a visual example to better explain myself but I can't post pictures.
You can use
CFrames because they contain rotation data so it is easier to move parts relative to each other. Just use the axis you want to choose the side, you know. I'm just going to give a script that you can change axis easily, I hope it isn't too advanced for you. Example:
local part1 local part2 local axis = "X" -- Use "X", "Y", or "Z" local reverse = false -- reverse side local offset = (part1.Size[axis] / 2) + (part2.Size[axis] / 2) * (reverse and -1 or 1) part1.CFrame = part2.CFrame * CFrame.new(axis == "X" and offset or 0, axis == "Y" and offset or 0, axis == "Z" and offset or 0)
The position of the top surface of a part will always be
Part.Position.Y + Part.Size/2 --To set it on the top part do partToSet.Position.Y = otherPart.Position.Y + otherPart.Size.Y/2 + partToSet.Size.Y/2
try playing around with it to get your desired results