ScriptContext

Show Deprecated
Not Creatable
Service
Not Replicated

This service controls all BaseScript objects. Most of the properties and methods of this service are locked for internal use, however you may use the ScriptContext.ScriptsDisabled property to disable all scripts from a thread with normal security access.

Summary

Properties

Sets whether BaseScript objects run their code. Scripts that are already running won't stop running.

HIDDEN

Methods

AddCoreScriptLocal(name: string, parent: Instance): void  


DeserializeScriptProfilerString(jsonString: string): table  CUSTOM LUA STATE


SaveScriptProfilingData(filename: string): void  


SetTimeout(seconds: number): void  

Limits how long a script is allowed to run without yielding.

StopScriptProfiling(): table  CUSTOM LUA STATE


Events

Error(message: string, stackTrace: string, script: Instance): RBXScriptSignal  

Fired when an error occurs.

ErrorDetailed(message: string, stackTrace: string, script: Instance, details: string, securityLevel: number): RBXScriptSignal  


Properties

ScriptsDisabled

Hidden
Local User Security
Local User Security

Sets whether BaseScript objects run their code. Scripts that are already running won't stop running.

Methods

AddCoreScriptLocal

void
Roblox Script Security

Parameters

name: string
parent: Instance

Returns

void

ClearScriptProfilingData

void
Roblox Script Security

Returns

void

DeserializeScriptProfilerString

Custom Lua State
Roblox Script Security

Parameters

jsonString: string

Returns

GetCoverageStats

Roblox Script Security

Returns

SaveScriptProfilingData

void
Roblox Script Security

Parameters

filename: string

Returns

void

SetTimeout

void
Plugin Security

Limits how long a script is allowed to run without yielding.

Parameters

seconds: number

Returns

void

StartScriptProfiling

void
Roblox Script Security

Returns

void

StopScriptProfiling

Custom Lua State
Roblox Script Security

Returns

Events

Error

Fired when an error occurs.

Parameters

message: string
stackTrace: string
script: Instance

Code Samples

ScriptContext.Error

local ScriptContext = game:GetService("ScriptContext")
local function onError(message, trace, script)
print(script:GetFullName(), "errored!")
print("Reason:", message)
print("Trace:", trace)
end
ScriptContext.Error:Connect(onError)
-- Somewhere, in another script
error("Error occurred!")

ErrorDetailed

Roblox Script Security

Parameters

message: string
stackTrace: string
script: Instance
details: string
securityLevel: number