How to prevent part from colliding with another part in dragging system

How would I stop these two parts from colliding?

	if isMouseDown == true and Target ~= nil then
		Target.Position = Mouse.Hit.Position +,0.7,0)

Script Testing - YouTube

1 Like

You can create a collision group to prevent the 2 parts from colliding

It does not exactly work to well. I still receive the same outcome.

You have to set up a Mouse target filter so the mouse doesn’t obtain the hit position of the object you are trying to not be collide with. The part would then move onto the ground behind the wall instead of against the wall, as shown in the video you posted.

What would i set the mouse target filter to?

a table of objects that you want the mouse to ignore.

for example: local filter = { workspace.Part1, workspace.Part2, }

Mouse.filter only accepts one instance

But every instance under that instance will also be included

tho you can’t save instances to tables

yea thats what I was thinking also.

Oh I am sorry, I got confused with another filtering thing.

You could just use a “Model” as a folder of parts, then put parts in there that you want filtered since it does get all child objects.

I made a custom dragger that uses raycasting with raycastParams instead of Mouse Filter, although this might be a bit expensive.

local flatSurface ='Part'
flatSurface.Anchored = true
flatSurface.CanCollide = false
flatSurface.Transparency = 1
flatSurface.Size =,2,100)
flatSurface.Parent = workspace

local cam = workspace.Camera
local mouse = game.Players.LocalPlayer:GetMouse()

local rayDragParamas =
rayDragParamas.FilterType = Enum.RaycastFilterType.Whitelist
rayDragParamas.FilterDescendantsInstances = {flatSurface}

local target, dragging = nil, false
local yFlat =,0,1)
local targetOffset =

mouse.TargetFilter = flatSurface

	if dragging and target then
		local ray = workspace:Raycast(cam.CFrame.Position,mouse.Origin.LookVector*128,rayDragParamas)
		if ray then
			target.Position = ray.Position*yFlat+targetOffset
			flatSurface.Position = ray.Position-Vector3.yAxis

	target = mouse.Target
	if target then
		dragging = true
		flatSurface.Position = mouse.Hit.Position-Vector3.yAxis
		targetOffset = (target.Position - mouse.Hit.Position)*yFlat + target.Position*Vector3.yAxis
	target, dragging = nil, false

edit: im making lots of edits in the code to make it run better, and look exactly like the studio dragger