How would I add a snap grid to my code?

Hi! I’ve been working on a script that gives the player an ability to place a wall (for building mechanics). I’ve achieved this, but I don’t know how I would alter my script to make it snap to grid. Right now, the build just follows the players mouse wherever they go, and they can place it. I would want it to be that the build snaps so the building is easier and looks a lot better.
(This is in a local script).

My code (shortened)

local mouse = game.Players.LocalPlayer:GetMouse()
local clonnedbrick = game.ReplicatedStorage.Wall:Clone()
while mouse ~= nil do
clonnedbrick.Position = mouse.Hit.p + Vector3.new(0,2,0)
end

All help is greatly appreciated

This isn’t working.
Would I put this in the while mouse ~= nil statement or how would I incorporate this in my format/script?