Part is following the mouse in its center

Basically is a placement system where a green part indicates where your placing an object. Though its following the mouse.

This video will explain:
robloxapp-20220212-1731185.wmv (1.6 MB)

Ive tried adding a primary part, the pivot point, etc. Not sure how to fix it.

So is there any way (By code preferably) that I can do to fix this?

No, Half of the part is in the floor. Because the part is following the mouse through its center. Sorry its confusing. I want the part to not go into the floor like that.

I was thinking you can add half the wall’s hight to it (assuming that it is the center of the wall going to the mouse)

I think you should do

local newPosition = position + greenBlock.Size.Y / 2

Because you don’t know how tall the ā€œgreen blockā€ is, and it is more dynamic this way

Edit: Maybe you need to do

local newPosition = position + Vector3.new(0, greenBlock.Size.Y / 2, 0)

Because I’m decently sure greenBlock.Size.Y returns a integer not a vector3

2 Likes

This is correct, you’d just need to add half the part’s height (Y-axis), to its position (also Y-axis). The position property of a part always describes its center point.

And position is mouse.hit.p right?

--------------------‐----------‐------

im decently sure mouse.hit gives you a cframe