Placement grid problem

Hello, I have a grid system. It doesn’t works quite well. The problem is, if you place a block on top of a block it works fine, but if you place a block on the side of the block that stands on top of a block, it will basically place a block inside of it. It depends on sides, for example: You go away from the centre of the map (basically (0,0,0) position) and place a block and then place a block on the side of it. It might place or not, so like it places if the side is facing away from the centre else it will be placed inside of that block.

 		local part ="Part")
		part.Parent = workspace
		part.TopSurface = Enum.SurfaceType.Smooth
		part.BottomSurface = Enum.SurfaceType.Smooth
		part.Size =,4,4)
		part.Position =*g,math.round(mousePos.Y/g)*g+2,math.round(mousePos.Z/g)*g)

If anyone knows how to fix the issue please let me know. If you still not aware what I’m talking about make sure to reread it or ask me so I can explain in details.

Try changing a little bit of the distance between these two parts or try setting it to Anchored.

That is not the issue I have in my script…

I need a remade script and a guide how does remade script works