Skip to content

Instantly share code, notes, and snippets.

@Sleitnick
Created March 19, 2025 06:06
Show Gist options
  • Select an option

  • Save Sleitnick/883dea78f441443a001ddb96742c03eb to your computer and use it in GitHub Desktop.

Select an option

Save Sleitnick/883dea78f441443a001ddb96742c03eb to your computer and use it in GitHub Desktop.

Revisions

  1. Sleitnick created this gist Mar 19, 2025.
    18 changes: 18 additions & 0 deletions find.luau
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    --!strict

    local function find(parent: Instance, ...: string): Instance
    local instance = parent

    for i = 1, select("#", ...) do
    local name = (select(i, ...))
    local inst = instance:FindFirstChild(name)
    if inst == nil then
    error(`failed to find instance "{name}" in {instance:GetFullName()}`, 2)
    end
    instance = inst
    end

    return instance
    end

    return find