Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to find the position of a parts surface? Placement System

Asked by 3 years ago

So I have a placement system that utilizes mouse.hit.position but the problem is... OK Mouse.Hit.Position does return the position of the parts surface but it always goes inside of the parts because Mouse.Hit.Position returns the center of whatever position the mouse is pointing on

So If I had a baseplate

and I wanted to place something on the baseplate using Mouse.Hit.Position the placement system would always place blocks inside of the baseplate meaning atleast half of the part would be submerged into the baseplate

So I want to try and place the blocks on top of the surface not under or even a bit submerged under the surface.

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

If it's a cube and the Baseplate is plain you can add the Size.Y/2 to the position

local ToMove = workspace.Part --it's the part should be placed
local Hit = Mouse.Hit

ToMove.CFrame = CFrame.new(Hit.Position + Vector3.new(ToMove.Size.Y/2))

It should work, if it's a model you can set the position by hand

Ad

Answer this question