getthreadidentity
Returns the thread identity level of the current execution thread.
function getthreadidentity(): numberSynopsis
How it works
Reads the security identity level from the current Luau thread's internal context. Roblox uses a numeric identity system (0–8) to control API access:
- 0 — Untrusted (no special access)
- 1–2 — LocalScriptLocalScriptA Roblox script type that runs on the client (player's machine). Has access to client-only APIs like UserInputService, Camera, and local player. Executes in the context of the local Player. / Script (normal game scripts)
- 3–4 — Plugin/CommandBar
- 5–6 — RobloxScript
- 7–8 — CoreScript (full access to all APIs)
VM internals
Each
lua_State (Luau thread) carries an extraSpace struct that includes a context / identity field. This integer is checked by Roblox C++ API methods before allowing calls to restricted services like DataModel:GetService("CoreGui").Usage
Check current identity
print(getthreadidentity()) "cc">--> 3 (typical executor identity)Returns
number Integer identity level of the current thread (0–8).
Aliases
Also available as getidentity and getthreadcontext.