Threads

setthreadidentity

Sets the identity for the current Luau thread, or for a provided Luau thread.

Syntax

setthreadidentity(thread?: thread, identity: number)
Aliases set_thread_identitysetidentitysetthreadcapssetthreadcontextset_thread_context

Arguments

NameTypeDescription
thread?threadOptional Luau thread to update. When provided as argument 1, identity must be passed as argument 2. If argument 1 is not a thread, it is treated as identity instead and the current thread is updated.
identitynumberIdentity value to apply. It is converted to an integer, clamped to the range 0 with 12, and then applied.

Description

Sets the identity for the current Luau thread, or for a provided Luau thread. Identity values are converted to integers and clamped to the supported range 0 through 12.

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

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Set the identity on the current Luau thread, or on a thread argument when one is provided.

local previous = getthreadidentity()

setthreadidentity(8)
print(getthreadidentity())

setthreadidentity(previous)