Part moving system grid

I would like to build a part moving system similar to game scp3008 and I’ve gotten a moving system but I don’t have a grid nor do I know how to implant one this is my current script to move parts

local mouse = plr:GetMouse()
local moving = false
local uis = game:GetService("UserInputService")

mouse.Button1Down:Connect(function(hit)
	local target = mouse.Target
	if target.Name == "Part" then
		target.Transparency = 0.5
		target.CanCollide = false
		target.CanTouch = false
		target.CanQuery = false
		moving = true
		uis.InputBegan:Connect(function(inp)
			if inp.KeyCode == Enum.KeyCode.R then
				if target.Name == "Part" then
					target.Orientation += Vector3.new(0,0,45)
					end
				elseif inp.KeyCode == Enum.KeyCode.T then
					if target.Name == "Part" then
						target.Orientation += Vector3.new(45,0,0)
				end
			end
		end)
	end
	mouse.Button1Up:Connect(function()
		if target.Name == "Part" then
		moving = false
		target.Transparency = 0
		target.CanCollide = true
		target.CanTouch = true
		target.CanQuery = true
			target.Position = Vector3.new(mouse.Hit.X, mouse.Hit.Y+2, mouse.Hit.Z)
			target = game.ReplicatedStorage.Base
		end
	end)
	while moving == true do
		if target.Name == "Part" then
			target.Position = Vector3.new(mouse.Hit.X, mouse.Hit.Y+2, mouse.Hit.Z)
			wait()
		end
	end
end)

I figured it out for anyone wondering just use Vector3.new(math.round(mouse.Hit.X,10), mouse.Hit.Y+2, math.round(mouse.Hit.Z,10))

1 Like