API:Class/Instance/FindFirstChildOfClass

FindFirstChildOfClass

Function of Object Icon.pngInstance
Ref<Instance> FindFirstChildOfClass (
    string className
)
Parameters:
  1. className

Returns: Ref<Instance>
Description: Returns the first Instance whose ClassName is equal to className, or nil, if no such object is found with that ClassName.

Example

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