Scripts

getcallingscript

Returns the Script Instance associated with the current Luau thread, or nil when no script is associated with it.

Syntax

getcallingscript(): Instance | nil

Returns

NameTypeDescription
scriptInstance | nilScript Instance associated with the current Luau thread, or nil.

Description

Returns the Script Instance associated with the current Luau thread, or nil when no script is associated with it.

Call it without parameters. The function reads the needed context from the current runtime state.

It returns script (Instance | nil). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = getcallingscript()
print(result)