setthreadidentity Synchronous

  • set_thread_context
  • set_thread_identity
  • setidentity
  • setthreadcaps
  • setthreadcontext
  • syn.set_thread_identity

Change the execution identity of the calling coroutine. If a task temporarily changes identity, save the previous value and restore it even when the task fails.

Syntax
Luau
setthreadidentity(identity: number) -> ()

Parameters

Function parameters
ParameterTypeDescription
identitynumberIntegral, representable identity number to apply to this coroutine.

Returns

()

No values.

Usage notes

Non-finite, fractional, and out-of-range numbers are accepted as no-ops. A numeric argument of the wrong type raises.

This changes the calling coroutine; it does not change every thread in the VM.

Example

Example
Luau
local previous = getthreadidentity()
local ok, reason = pcall(function()
    setthreadidentity(2)
    print("Temporary identity:", getthreadidentity())
end)
setthreadidentity(previous)
if not ok then error(reason) end
Kawaii documentation