function MoveTool.PrepareSelectionForDragging(z)local c={}local I={}local u=Support.FlipTable(Selection.Parts)for z,I in pairs(Selection.Parts)do c[I]={Anchored=I.Anchored,CanCollide=I.CanCollide,CFrame=I.CFrame}I.Anchored=true I.CanCollide=false c[I].Joints=Core.PreserveJoints(I,u)I:BreakJoints()I.Velocity=Vector3.new()I.RotVelocity=Vector3.new()end pcall(function()for z,c in ipairs(Selection.Models)do I[c]={Pivot=c:GetPivot()}end end)local F local P=Selection.Focus if not P then F=nil elseif P:IsA("\066\097\115\101\080\097\114\116")then F=P.CFrame elseif P:IsA("\077\111\100\101\108")then F=P:GetModelCFrame()pcall(function()F=P:GetPivot()end)end return c,I,F end
--- Prepares selection for dragging, and returns the initial state of the selection.
function MoveTool:PrepareSelectionForDragging()
	local InitialPartStates = {}
	local InitialModelStates = {}

	-- Get index of parts
	local PartIndex = Support.FlipTable(Selection.Parts)

	-- Stop parts from moving, and capture the initial state of the parts
	for _, Part in pairs(Selection.Parts) do
		InitialPartStates[Part] = {
			Anchored = Part.Anchored,
			CanCollide = Part.CanCollide,
			CFrame = Part.CFrame,
		}
		Part.Anchored = true
		Part.CanCollide = false
		InitialPartStates[Part].Joints = Core.PreserveJoints(Part, PartIndex)
		Part:BreakJoints()
		Part.Velocity = Vector3.new()
		Part.RotVelocity = Vector3.new()
	end

	-- Get initial model states (temporarily pcalled due to pivot API being in beta)
	pcall(function()
		for _, Model in ipairs(Selection.Models) do
			InitialModelStates[Model] = {
				Pivot = Model:GetPivot(),
			}
		end
	end)

	-- Get initial state of focused item
	local InitialFocusCFrame
	local Focus = Selection.Focus
	if not Focus then
		InitialFocusCFrame = nil
	elseif Focus:IsA("BasePart") then
		InitialFocusCFrame = Focus.CFrame
	elseif Focus:IsA("Model") then
		InitialFocusCFrame = Focus:GetModelCFrame()
		pcall(function()
			InitialFocusCFrame = Focus:GetPivot()
		end)
	end

	return InitialPartStates, InitialModelStates, InitialFocusCFrame
end
