Find an object that can be in multiple paths

I would like to know how I can find an object that can be in multiple paths.

Like doing this:

local checkmark = player.PlayerGui.Inventory.Frame.Trails:FindFirstChild("CheckMark")

But insted of it just searching in Trails, it would search in all paths inside player.PlayerGui.Inventory.Frame.Trails:

Can someone help me?

There may be a better way, however, this should work:

function FindInstance(ToSearch)
	for i, v in pairs (ToSearch:GetDescendants()) do
		if v.Name == "CheckMark" then
			return v
		end
	end
end

print(FindInstance(player.PlayerGui.Inventory.Frame.Trails))
1 Like