Correctly converting a number to an int or other method to fix my building tool

So, I am making an advanced raft survival game and one of the tools in the game is a building tool. I need to round the position of the part that I place to the nearest stud for that tool though. The only method I have found is math.floor(var + 0.5). This method I am pretty sure is making the part offset by a few pixels and this happens. You cannot place blocks in the negative axis because of the small offset as shown near the end of this video:

what2.wmv

oh and here’s the script for placin the block:

wait()
script.Parent.Activated:Connect(function()
	local Player = game.Players.LocalPlayer
	local Mouse = Player:GetMouse()
	
	local NewPart = Instance.new("Part")
	
	NewPart.Size = Vector3.new(1,1,1)
	
	NewPart.Parent = workspace
	
	NewPart.Anchored = true
		
	NewPart.Position = Vector3.new(math.floor(Mouse.Hit.Position.X + 0.5), math.floor(Mouse.Hit.Position.Y + 0.5), math.floor(Mouse.Hit.Position.Z + 0.5))
	NewPart.Position = Vector3.new(NewPart.Position.X, NewPart.Position.Y + NewPart.Size.Y/2, NewPart.Position.Z)
	
	
	print(NewPart.Position)	
end)

I’m pretty new to scripting in lua, So sorry if the answer is obvious.

don’t use math.floor like that, math.round is used to round a number to the nearest integer

Vector3.new(math.round(Mouse.Hit.Position.X), math.round(Mouse.Hit.Position.Y), math.round(Mouse.Hit.Position.Z))

how the heck did I not know that exists.

Wait. But that does the same thing for some reason. Maybe I have something wrong with a different part of my code?

math.floor(N + 0.5) is the same as math.round(N)
you are fine, math.round is should be used though
why use math.floor like that if math.round is built in

No, I mean that It does not work still.

I know what you mean, I was quoting your other statement
I don’t really want to download a video

Ohhhh here

You see when I try to add a block to a different block in the - axis then it clips through it.