Scripts

getinstancesbyclass

Returns instances from the Instance cache table whose ClassName field exactly matches the requested string.

Syntax

getinstancesbyclass(className: string): table
Aliases getinstancesofclass

Arguments

NameTypeDescription
classNamestringExact ClassName string to match. Empty strings raise "ClassName required".

Returns

NameTypeDescription
instancestableNew array table containing matching object values from the Instance cache table.

Description

Returns instances from the Instance cache table whose ClassName field exactly matches the requested string. The first argument is required to be a string. An empty string raises "ClassName required". The function creates a new array table, iterates the cache stored under Instance cache, keeps only values whose Lua type is object, reads each object value's ClassName field, and compares it with strcmp against the requested className. Matches are inserted sequentially starting at index 1. The match is exact and case-sensitive. The function does not use IsA, does not include subclasses, does not walk descendants, does not filter by Parent, and does not sort the result. getinstancesofclass is an alias for the same function.

Call it with 1 parameter(s): className. The argument table explains which values are required and which ones only refine the behavior.

It returns instances (table). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = getinstancesbyclass("example")
print(result)