local b=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(E,p,l)local m={}for E,p in pairs(GetChildren(E))do if b[p.ClassName]and(l[p.Part0]and l[p.Part1])then m[p]=p.Parent end end return m end function RestoreJoints(b)for b,E in pairs(b)do b.Parent=E end end function PreserveJoints(b,E)local p=GetPartJoints(b,E)for b in pairs(p)do b.Parent=nil end return p end
-- Types of joints to assume should be preserved
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
