I've been trying to make a Grid placement script, this is what I have:
Player = game.Players.LocalPlayer
Part = game.Workspace.TestPart
Mouse = Player:GetMouse()
MouseDown = false
function SnapToGrid()
return CFrame.new(
math.floor(Mouse.Hit.X * 0.5 + 0.5) * 2,
math.floor(Part.CFrame.Y),
math.floor(Mouse.Hit.Z * 0.5 + 0.5) * 2
)
end
Mouse.Button1Down:connect(function()
if Mouse.Target.Name == "TestPart" then
MouseDown = true
repeat
wait()
Part.CFrame = SnapToGrid()
until MouseDown == false
end
end)
Mouse.Button1Up:connect(function()
MouseDown = false
end)
But it doesn't exactly work... I've been trying to mess around with the numbers, but it doesn't seem to fix it. Anyone know what i'm doing wrong?

2 comments
Thank you it works but it doesn't correctly align with the grid. Would I need to move my grid? Or is there a different way to align it?
I think that you mean that the outer borders do not align with it? I fixed that by taking the Y size (Just manually putting an intvalue in every model, and then you can do like (2.625 / 5 ) ==> 1*5 =5 + (The value / 2) I'm nto sure if that would work, since I can't see what you mean with "Doesn't correctly align"