ReferenceReflection

setthreadidentity

Changes the security identity of the current thread.

Syntax

setthreadidentity(identity: number) -> ()

Also available as

setidentitysetthreadcontextset_identityset_thread_contextset_thread_identity

Parameters

ParameterTypeDescription
identitynumberAn integer from 0 to 8.

Description

Lowering the identity makes your code behave like a game script for permission checks; raising it gives access to APIs protected at that level. The change applies to the current thread and to threads it starts afterwards.

Example

setthreadidentity(2)
print(getthreadidentity())
print(pcall(function() return game:GetService("CoreGui").Name end))

setthreadidentity(8)
print(pcall(function() return game:GetService("CoreGui").Name end))

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.