Threads

getthreadidentity

Returns the identity for the current Luau thread, or for the first argument when that argument is a thread.

Syntax

getthreadidentity(thread?: thread): integer
Aliases get_thread_identitygetidentitygetthreadcapsgetthreadcontextget_thread_context

Arguments

NameTypeDescription
thread?threadOptional Luau thread to inspect. If omitted, or if the first argument is not a thread, the current thread is inspected.

Returns

NameTypeDescription
identityintegerThread identity from 1 through 12, or 0 for other stored values.

Description

Returns the identity for the current Luau thread, or for the first argument when that argument is a thread. Returned identities are 1 through 12; other stored values return 0.

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

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

Example

Read the identity from the current Luau thread, or from a thread argument when one is provided.

local currentIdentity = getthreadidentity()
print(currentIdentity)

local thread = coroutine.create(function()
end)

print(getthreadidentity(thread))