Building system issue

Hello, I’m currently working on a block placement system, and I’m trying to find a way for the blocks to connect to surfaces. I’ve spent hours trying to figure this out, but I still cannot find a solution. In simpler terms, the block needs to perfectly connect against the surface my mouse is pointing on.

Can you use weld constraints to connect them?

Sorry, I was just taking images.

What I want:
As you can see, the block is perfectly stacked on top of the other.

What I have:

Instead of being on top of the block, it’s center is at the mouse position. Sure you could do something with UpVector, but it would only work on specific surfaces.

Maybe you could use half of the Y size of mouse.Target to add to the part’s Y position.

Sorry if this sounds really dumb, I’m not advanced with CFrames and positioning yet.

edit: Sorry, I realized this wouldn’t work for all parts maybe try moving the part that it locked to the mouse position up by half of it’s Y size.

1 Like

okk so for positions, the default pivot is in the center of the block. Roblox is working on an update to change pivots, but so far I haven’t kept up with it too much.

To fix your problem of the block going into the center, all you have to do is get the original block’s Y size. Divide that by two and Add it to it’s position.

1 Like

Oh, sorry I forgot to give my code.

	local Params =
	Params.FilterDescendantsInstances = {newGrass.Part, newGrass.PrimaryPart, Player.Character}
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	local RayResult = workspace:Raycast(Camera.CFrame.Position, (Mouse.hit.p - Camera.CFrame.Position).unit * 1000, Params)
	if RayResult then
		--newGrass.Part.CFrame = - % 1, RayResult.Position.Y % 1, RayResult.Position.Z % 1))  
		newGrass.Part.CFrame = CFrame.lookAt(RayResult.Position - % 1, RayResult.Position.Y % 1, RayResult.Position.Z % 1), RayResult.Position + RayResult.Normal) * CFrame.Angles(0,0, math.rad(0))  

is there any way I can use normals to accomplish my goal? I’m doing this because I need to place the blocks off of each other horizontally when in the air. (Sort of like bridging in minecraft if you’ve ever played the game.)

yeye, It should be the same except with a bit more stuff. I myself haven’t done it, but my very tired brain is telling me all you gotta do is somehow get the axis you’re placing it at then getting the size on that axis and dividing it by 2. So if you’re placing it on the x axis, get the x size/2 then adding that to the x axis.

i hope that makes sense, i really can’t think straight right now.

1 Like

that’s ok! I’ve been searching for hours and I’ve been tired too. Also one last thing, where did you learn this “formula” of dividing the size by two? I’m assuming the two is supposed to represent two objects, and the Y some sort of length.

Geometry class lol. Also a mix of trial and error.

1 Like