Node not moving in the expected direction

I wanted to include roofs in the build mode system I’ve been working on. Everything ran smoothly. Up until I ran into a significant issue.

In this video, you can see that nodes are a little higher than anticipated. They are therefore not in contact with the baseplate. And that’s the issue.

My code is easy to understand. When the button is activated, it toggles a boolean which allows me to move two nodes, that should create a roof. Here’s the part where I activate the movement of the two parts:

Mouse.Move:Connect(function()
	if Mouse.Target then
		if Toggle then
			if Counter == 1 then
				PointA.Parent = workspace
				PosA = Vector3.new(Round(Mouse.Hit.p.X, Grid), 0, Round(Mouse.Hit.p.Z, Grid)) 
				PointA.CFrame = CFrame.new(PosA)
			elseif Counter == 2 then
				PointB.Parent = workspace
				PosB = Vector3.new(Round(Mouse.Hit.p.X, Grid), 0, Round(Mouse.Hit.p.Z, Grid)) 
				PointB.CFrame = CFrame.new(PosB)
          end
      end
   end
end)

If you are wondering, PosA and PosB are found in this code:

local pos1 = PointA.Position
local pos2 = PointB.Position

local diff = pos2-pos1
part.Position = (pos1+pos2)/2
				
PosA = pos1
PosB = PosB

Any help is appreciated! Thank you.

You could check if the mouse did not hit anything. Like so:

if Mouse.Hit ~= nil then
    -- code here
end

Mouse is deprecated please use UserInputService and ContextActionService, if you have code relating to mouse objects.

1 Like

Thanks for the reply, but that can’t fix my problem.

Is there any way we could lower its Y axis?

I guess I’ll try to figure it out…

you could do Mouse.Hit.Y.
[Char Limit]

1 Like

Works! Thanks.

I was kinda stupid tbh lol.

1 Like