local w=Support.FlipTable({"\087\101\108\100";"\077\097\110\117\097\108\087\101\108\100";"\077\097\110\117\097\108\071\108\117\101";"\077\111\116\111\114","\077\111\116\111\114\054\068"})function SearchJoints(r,e,b)local V={}for r,e in pairs(GetChildren(r))do if w[e.ClassName]and(b[e.Part0]and b[e.Part1])then V[e]=e.Parent end end return V end function RestoreJoints(w)for w,r in pairs(w)do w.Parent=r end end function PreserveJoints(w,r)local e=GetPartJoints(w,r)for w in pairs(e)do w.Parent=nil end return e end

local ManualJointTypes = Support.FlipTable { 'Weld', 'ManualWeld', 'ManualGlue', 'Motor', 'Motor6D' };

function SearchJoints(Haystack, Part, Whitelist)
	-- Searches for and returns manual joints in `Haystack` involving `Part` and other parts in `Whitelist`

	local Joints = {};

	-- Search the haystack for joints involving `Part`
	for _, Item in pairs(GetChildren(Haystack)) do

		-- Check if this item is a manual, intentional joint
		if ManualJointTypes[Item.ClassName] and
		   (Whitelist[Item.Part0] and Whitelist[Item.Part1]) then

			-- Save joint and state if intentional
			Joints[Item] = Item.Parent;

		end;

	end;

	-- Return the found joints
	return Joints;

end;

function RestoreJoints(Joints)
	-- Restores the joints from the given `Joints` data

	-- Restore each joint
	for Joint, JointParent in pairs(Joints) do
		Joint.Parent = JointParent;
	end;

end;

function PreserveJoints(Part, Whitelist)
	-- Preserves and returns intentional joints of `Part` connecting parts in `Whitelist`

	-- Get the part's joints
	local Joints = GetPartJoints(Part, Whitelist);

	-- Save the joints from being broken
	for Joint in pairs(Joints) do
		Joint.Parent = nil;
	end;

	-- Return the joints
	return Joints;

end;
