I'm trying to make a build system in my game and when you move your mouse it fires a function which is supposed to make the part move by 2 studs but when you move your mouse it moves 2 studs but it isn't in grid or orientation accordingly to where the grid texture is on the baseplate. Here's my script (portion of it)
local function SnapToGrid()
PosX, PosY, PosZ = math.floor(Mouse.Hit.X / Grid + 0.5) * Grid, math.floor(Mouse.Hit.Y / Grid + 1) * Grid, math.floor(Mouse.Hit.Z / Grid + 0.5) * Grid
end
local function MouseMoved()
Object.PrimaryPart.Position = Vector3.new(PosX, PosY, PosZ)
SnapToGrid()
end
local function CloneService(Obj)
Object = game.ReplicatedStorage.BuildObjects:FindFirstChild(Obj):Clone()
Object.Parent = Plot
Object.PrimaryPart.Orientation = Vector3.new(0, PlotY, 0)
Mouse.Move:Connect(MouseMoved)
end
Soil.MouseButton1Click:Connect(function()
CloneService("Soil")
end)
Can someone tell me how to make the moveable part align up with the baseplate and move by two studs. When it does move the part it goes somewhat diagonal. please HELP!

3 comments
(math.floor(Mouse.Hit.X / Grid + 1)/Grid) * Grid try that.. Also, I recommend using ego mooses placement system or tunicus's system
doing the "+1" did not work.... do you have any other ideas because i would rather not try a new script with mine pretty much finished.... also I did look at one and just curious why would mass be needed for placement or moving??
Also what I've seen was that when I move the part diagonal it moved in the grid but when I move my mouse forward it would not be in a grid