getcallingscript Synchronous
Find the script Instance associated with the current call, when the runtime has that context. It can help label diagnostics produced by code running on behalf of a script.
Luau
getcallingscript() -> ScriptInstance?Parameters
This function takes no arguments.
Returns
ScriptInstance?A Script, LocalScript, or ModuleScript, or nil when no calling script is available.
Usage notes
Code launched directly in the executor may have no associated script. Check for nil before accessing properties.
Example
Luau
local scriptInstance = getcallingscript()
print(scriptInstance and scriptInstance:GetFullName() or "No calling script")