local M=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(B,S,q)local Q={}for B,S in pairs(GetChildren(B))do if M[S.ClassName]and(q[S.Part0]and q[S.Part1])then Q[S]=S.Parent end end return Q end function RestoreJoints(M)for M,B in pairs(M)do M.Parent=B end end function PreserveJoints(M,B)local S=GetPartJoints(M,B)for M in pairs(S)do M.Parent=nil end return S end function CreatePart(M)local B if M=="\078\111\114\109\097\108"then B=Instance.new("\080\097\114\116")B.Size=Vector3.new(4,1,2)elseif M=="\084\114\117\115\115"then B=Instance.new("\084\114\117\115\115\080\097\114\116")elseif M=="\087\101\100\103\101"then B=Instance.new("\087\101\100\103\101\080\097\114\116")B.Size=Vector3.new(4,1,2)elseif M=="\067\111\114\110\101\114"then B=Instance.new("\067\111\114\110\101\114\087\101\100\103\101\080\097\114\116")elseif M=="\067\121\108\105\110\100\101\114"then B=Instance.new("\080\097\114\116")B.Shape="\067\121\108\105\110\100\101\114"B.Size=Vector3.new(2,2,2)elseif M=="\066\097\108\108"then B=Instance.new("\080\097\114\116")B.Shape="\066\097\108\108"elseif M=="\083\101\097\116"then B=Instance.new("\083\101\097\116")B.Size=Vector3.new(4,1,2)elseif M=="\086\101\104\105\099\108\101 \083\101\097\116"then B=Instance.new("\086\101\104\105\099\108\101\083\101\097\116")B.Size=Vector3.new(4,1,2)elseif M=="\083\112\097\119\110"then B=Instance.new("\083\112\097\119\110\076\111\099\097\116\105\111\110")B.Size=Vector3.new(4,1,2)end B.TopSurface=Enum.SurfaceType.Smooth B.BottomSurface=Enum.SurfaceType.Smooth B.Anchored=true return B 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;

function CreatePart(PartType)
	-- Creates and returns new part based on `PartType` with sensible defaults

	local NewPart

	if PartType == 'Normal' then
		NewPart = Instance.new('Part')
		NewPart.Size = Vector3.new(4, 1, 2)

	elseif PartType == 'Truss' then
		NewPart = Instance.new('TrussPart')

	elseif PartType == 'Wedge' then
		NewPart = Instance.new('WedgePart')
		NewPart.Size = Vector3.new(4, 1, 2)

	elseif PartType == 'Corner' then
		NewPart = Instance.new('CornerWedgePart')

	elseif PartType == 'Cylinder' then
		NewPart = Instance.new('Part')
		NewPart.Shape = 'Cylinder'
		NewPart.Size = Vector3.new(2, 2, 2)

	elseif PartType == 'Ball' then
		NewPart = Instance.new('Part')
		NewPart.Shape = 'Ball'

	elseif PartType == 'Seat' then
		NewPart = Instance.new('Seat')
		NewPart.Size = Vector3.new(4, 1, 2)

	elseif PartType == 'Vehicle Seat' then
		NewPart = Instance.new('VehicleSeat')
		NewPart.Size = Vector3.new(4, 1, 2)

	elseif PartType == 'Spawn' then
		NewPart = Instance.new('SpawnLocation')
		NewPart.Size = Vector3.new(4, 1, 2)
	end

	-- Make part surfaces smooth
	NewPart.TopSurface = Enum.SurfaceType.Smooth;
	NewPart.BottomSurface = Enum.SurfaceType.Smooth;

	-- Make sure the part is anchored
	NewPart.Anchored = true

	return NewPart
end
