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
| Name | Type | Description |
|---|---|---|
className | string | Class or supported base class to test with IsA(). |
recursive | boolean? | When true, searches descendants instead of only direct children. |
return | Instance or nil | The 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())
endExample: 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)