ScriptContext

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

無法建立
服務
未複製

此服務控制所有 BaseScript 對象。此服務的大多數屬性和方法用於內部使用。

屬性

方法

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