--!strict

local function GetAllParts(instance: Instance, includeParent: boolean?): {BasePart}
	local parts = {}
	
	if type(includeParent) ~= "boolean" then
		includeParent = true
	end
	
	if instance:IsA("BasePart") and includeParent == true then
		table.insert(parts, instance::BasePart)
	end
	
	for _, child: BasePart in ipairs(instance:GetDescendants()) do
		if child:IsA("BasePart") then
			table.insert(parts, child)
		end
	end
	
	return parts
end

return GetAllParts
