Safe move for parts

Hi! I’m working on building tools similar to the classic ones (move, clone, delete) and I need a way to ‘safe move’ parts out of other intersecting parts. This behaviour if I remember correctly is available through setting Position directly, but that’s not very future proof as there has been intention of removing that feature, so I would like a Lua implementation.

My current code does not work correctly, and is approximate at best:

local function moveUpUntilFree(part)
	local wasAnchored = part.Anchored
	part.Anchored = true
	while #part:GetTouchingParts() > 0 do
		part.CFrame = part.CFrame +, 0.1, 0)
	part.Anchored = wasAnchored 

The ideal solution would:

  • preserve properties like Anchored
  • provide a more exact position for the part, rather than this kind of rough approximation
  • work with all kinds of parts and part shapes

What would be the best way of implementing such a function?


The removal of safe move is unlikely to happen as many games likely rely on that behavior and would break. If it were to be removed, an alternative would likely be provided, or it would be implemented such that it would not break existing games.

You shouldn’t worry about this if future proofing is your only reason for implementing this.


Nevertheless, consider raycasting straight down from above the part using the set of parts returned from GetTouchingParts as a whitelist. Then you can get the intersection point of the highest true surface and move the part there + it’s height offset (raycast up from under the part to determine this?).

1 Like

Wasn’t safe move by setting .Position removed when Moving to Workspace.AutoJointsMode = Explicit by Default in January, Forced in Febuary? You have to Model:MoveTo to explicitly safe move now, if I remember right.


You can wrap whatever you’re moving in a model and do :MoveTo(), which safely moves, and then remove it from the model once you’re done moving.

1 Like

I just ran into this case a few days ago, actually! Funny timing.

		--Move this part up until it intersects with nothing.
		--Funny little hack. :)
		local oldParent = part.Parent;
		local m ="Model");
		part.Parent = m;
		m.PrimaryPart = part;
		m.Parent = workspace;
		part.Parent = oldParent;

But yeah, everything others said is true. :stuck_out_tongue: