local function alignToGrid(pos)
local newPos = {}
for _, axis in ipairs({"X", "Z"}) do
local val = pos[axis]
local rem = (val - 2) % 4
if rem < 2 then
newPos[axis] = val - rem
elseif rem >= 2 then
newPos[axis] = val - rem + 4
end
end
return Vector3.new(newPos.X, 0, newPos.Z)
end
Idk if this works, made it off the top of my head :p
|