setthreadidentity Synchronous
set_thread_contextset_thread_identitysetidentitysetthreadcapssetthreadcontextsyn.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.
Luau
setthreadidentity(identity: number) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
identity | number | Integral, 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
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