ScriptContext

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建
服务
未复制

该服务控制所有 BaseScript 对象。该服务的大多数属性和方法用于内部使用。

概要

方法

  • SetTimeout(seconds : number):()
    插件安全性

    限制脚本在没有放弃的情况下运行的时间长度。

属性

方法

SetTimeout

()
插件安全性

限制脚本在没有放弃的情况下运行的时间长度。

参数

seconds: number
默认值:""

返回

()

活动

Error

在出现错误时发射。

参数

message: string
stackTrace: string
script: Instance

代码示例

When an error occurs, this example prints the name of the script that errored, the reason it errored, and a trace of the error.

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!")