Glorpia Docs
Scripting / Method

FindFirstChildWhichIsA()

Finds the first child that matches a class or one of Glorpia's supported base classes.

Syntax

instance:FindFirstChildWhichIsA(className, recursive?)

Parameters and return value

NameTypeDescription
classNamestringClass or supported base class to test with IsA().
recursiveboolean?When true, searches descendants instead of only direct children.
returnInstance or nilThe first matching object, or nil when no match exists.
Unlike FindFirstChildOfClass(), this method uses IsA(). For example, a Part can match "BasePart".

Example: Find Any BasePart

Luau
local firstPart = workspace:FindFirstChildWhichIsA("BasePart", true)

if firstPart then
    print(firstPart:GetFullName())
end

Example: Find A Humanoid

Luau
script.Parent.Touched:Connect(function(hit)
    local character = hit.Parent
    local humanoid = character and character:FindFirstChildWhichIsA("Humanoid")

    if humanoid then
        humanoid:TakeDamage(10)
    end
end)

Related