PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

FindFirstChildOfClass

Returns the first child of the Instance whose Instance/ClassName|ClassName is equal to the given className.

If no matching child is found, this function returns nil.

Unlike Instance/FindFirstChildWhichIsA this function uses only returns objects whose class matches the given className, ignoring class inheritance.

Developers looking for a child by name, should use Instance/FindFirstChild instead.

Parameters

Name Type Default Description

The Instance/ClassName to be looked for.

Returns

Return Type Summary

The Instance found.


Code Samples


Instance:FindFirstChildOfClass

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoid
while not humanoid do
    humanoid = character:FindFirstChildOfClass("Humanoid")
    if not humanoid then
        character.ChildAdded:wait()
    end
end