How could I make a part snap to grid? [closed]
I already have the moving part of the script but now I need to make the part snap to grid which the part in this case target:
01 | local plr = game.Players.LocalPlayer |
02 | local mouse = plr:GetMouse() |
05 | local plr = game.Players.LocalPlayer |
08 | if mouse.Target ~ = nil then |
09 | if mouse.Target.Parent = = game.Workspace [ plr.Name .. "w" ] then |
11 | mouse.TargetFilter = target |
16 | mouse.Button 1 Down:connect(gettarget) |
21 | local PosX,PosY,PosZ = mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z |
22 | target.Position = Vector 3. new(PosX,PosY,PosZ) |
26 | mouse.Move:connect(move) |
28 | function releasetarget() |
31 | mouse.TargetFilter = nil |
33 | mouse.Button 1 Up:connect(releasetarget) |
Also could you please explain to me how the snapping works?