How to make drag to move furniture

i have a placement system but it doesn’t work with a grid and i think a grid system would be better so it’s easier to place furniture evenly

something like adopt me’s drag to move system because this kind of furniture placement is the best for mobile and or computer

example:


i just want to know how to make my system work like this, it uses ray-casts by the way. not sure if there’s a better way

thanks so much for any help :heart:

Here’s some code that you can try using in StarterPlayerScripts:

local grid_size = 5

local mouse = game.Players.LocalPlayer:GetMouse()

local part = Instance.new("Part")
part.Size = Vector3.new(5, 5, 5)
part.Anchored = true
part.Parent = workspace

mouse.TargetFilter = part

game:GetService("RunService").RenderStepped:Connect(function()
	
	part.Position = Vector3.new(
		math.floor(mouse.Hit.X / grid_size) * grid_size + grid_size / 2,
		math.floor(mouse.Hit.Y / grid_size) * grid_size + grid_size / 2,
		math.floor(mouse.Hit.Z / grid_size) * grid_size + grid_size / 2
	)
	
end)

Essentially, this will snap the part to a 5x5x5 grid (or whatever grid size you desire). You can try using this in combination with the furniture system you already have, and hopefully everything goes well.

1 Like

okay sorry for the late reply. i procrastinated. one question. so i used your script and it works but i have this gird and each square is 4 studs but when moving a 4x4 block it doesn’t line up to my gird, how do i fix this?

and yes i did change the grid_size to 4

Screen Shot 2023-10-30 at 8.26.19 AM