此服務控制所有 BaseScript 對象。此服務的大多數屬性和方法用於內部使用。
概要
活動
發生錯誤時發射。
屬性
方法
活動
Error
發生錯誤時發射。
參數
範例程式碼
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!")