学ぶ
エンジンクラス
ScriptEditorService
作成できません
サービス
複製されていません

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。



APIリファレンス
方法
DeregisterAutocompleteCallback
プラグインのセキュリティ
ScriptEditorService:DeregisterAutocompleteCallback(name:string):()
パラメータ
name:string
戻り値
()
コードサンプル
DeregisterAutocompleteCallback()
local ScriptEditorService = game:GetService("ScriptEditorService")
-- "foo" のオートコンプリートコールバックを解除します。
ScriptEditorService:DeregisterAutocompleteCallback("foo")

DeregisterScriptAnalysisCallback
プラグインのセキュリティ
ScriptEditorService:DeregisterScriptAnalysisCallback(name:string):()
パラメータ
name:string
戻り値
()
コードサンプル
DeregisterScriptAnalysisCallback()
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService:DeregisterScriptAnalysisCallback("foo")

FindScriptDocument
プラグインのセキュリティ
ScriptEditorService:FindScriptDocument(script:LuaSourceContainer):ScriptDocument
パラメータ
コードサンプル
ScriptDocument:CloseAsync
--!nocheck
-- 次のコードをコマンドバーで実行します
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
local scriptDocument
-- 最初に開いているスクリプトドキュメントを見つける
for _, document in documents do
-- コマンドバーは閉じることができないので、選択しないでください
if not document:IsCommandBar() then
scriptDocument = document
break
end
end
if scriptDocument then
local success, err = scriptDocument:CloseAsync()
if success then
print(`閉じました {scriptDocument.Name}`)
else
warn(`{scriptDocument.Name} を閉じるのに失敗しました: {err}`)
end
else
print("開いているスクリプトはありません")
end
ScriptDocument.ViewportChanged への接続
--!nocheck
--[[
実行するには:
1. 出力ビューが開いていることを確認します
2. コマンドバーで以下のコードを実行します
3. 開いているスクリプトウィンドウで上下にスクロールします
ViewportChanged イベントからの印刷文は出力に表示されます
]]
local Workspace = game:GetService("Workspace")
local ScriptEditorService = game:GetService("ScriptEditorService")
-- 複数行にわたるテキストを作成
local dummyText = string.rep("-- ダミーテキスト\n", 60)
-- ダミーテキストを含むスクリプトを作成し、それを開く
local otherScript = Instance.new("Script")
otherScript.Source = dummyText
otherScript.Parent = Workspace
local success, err = ScriptEditorService:OpenScriptDocumentAsync(otherScript)
if not success then
warn(`スクリプトのオープンに失敗しました: {err}`)
return
end
-- 開かれたスクリプトへの参照を取得
local scriptDocument = ScriptEditorService:FindScriptDocument(otherScript)
local function onViewportChanged(startLine: number, endLine: number)
print(`スクリプトのビューポートが変更されました - 開始行: {startLine}, 終了行: {endLine}`)
end
-- 更新されたビューポートの開始行と終了行を印刷する上記の関数に ViewportChanged イベントを接続
scriptDocument.ViewportChanged:Connect(onViewportChanged)

GetEditorSource
プラグインのセキュリティ
ScriptEditorService:GetEditorSource(script:LuaSourceContainer):string
パラメータ
戻り値

GetScriptDocuments
プラグインのセキュリティ
ScriptEditorService:GetScriptDocuments():{ScriptDocument}
戻り値
コードサンプル
すべてのスクリプトの名前を印刷する
--!nocheck
-- コマンドバーで次のコードを実行します
local ScriptEditorService = game:GetService("ScriptEditorService")
local scriptDocuments = ScriptEditorService:GetScriptDocuments()
for _, scriptDocument in scriptDocuments do
-- 各スクリプトの名前を印刷します
if not scriptDocument:IsCommandBar() then
print(scriptDocument.Name)
end
end

OpenScriptDocumentAsync
イールド
プラグインのセキュリティ
ScriptEditorService:OpenScriptDocumentAsync(
パラメータ
options:Dictionary
既定値: "nil"
戻り値
コードサンプル
OpenScriptDocumentAsync()
--!nocheck
-- 次のコードをコマンドバーで実行します
local ScriptEditorService = game:GetService("ScriptEditorService")
local Workspace = game:GetService("Workspace")
local newScript = Instance.new("Script")
newScript.Parent = Workspace
local success, err = ScriptEditorService:OpenScriptDocumentAsync(newScript)
if success then
print("スクリプトドキュメントを開きました")
else
print(`スクリプトドキュメントを開くのに失敗しました: {err}`)
end

RegisterAutocompleteCallback
プラグインのセキュリティ
ScriptEditorService:RegisterAutocompleteCallback(
name:string, priority:number, callbackFunction:function
):()
パラメータ
name:string
priority:number
callbackFunction:function
戻り値
()
コードサンプル
RegisterAutocompleteCallback() および DeregisterAutocompleteCallback()
--!nocheck
-- コマンドバーで以下のコードを実行します。
local ScriptEditorService = game:GetService("ScriptEditorService")
type Request = {
position: {
line: number,
character: number,
},
textDocument: {
document: ScriptDocument?,
script: LuaSourceContainer?,
},
}
type Response = {
items: {
{
label: string,
kind: Enum.CompletionItemKind?,
tags: { Enum.CompletionItemTag }?,
detail: string?,
documentation: {
value: string,
}?,
overloads: number?,
learnMoreLink: string?,
codeSample: string?,
preselect: boolean?,
textEdit: {
newText: string,
replace: {
start: { line: number, character: number },
["end"]: { line: number, character: number },
},
}?,
}
},
}
local autocompleteCallback = function(request: Request, response: Response): Response
local item = {
label = "foo",
preselect = true,
}
table.insert(response.items, item)
return response
end
ScriptEditorService:RegisterAutocompleteCallback("foo", 1, autocompleteCallback)
-- コールバックを登録解除するには、コマンドバーで以下のコードを実行します。
ScriptEditorService:DeregisterAutocompleteCallback("foo")

RegisterScriptAnalysisCallback
プラグインのセキュリティ
ScriptEditorService:RegisterScriptAnalysisCallback(
name:string, priority:number, callbackFunction:function
):()
パラメータ
name:string
priority:number
callbackFunction:function
戻り値
()
コードサンプル
RegisterScriptAnalysisCallback()
type Request = {
["script"]: LuaSourceContainer,
}
type Response = {
diagnostics: {
{
range: {
start: {
line: number,
character: number,
},
["end"]: {
line: number,
character: number,
},
},
code: string?,
message: string,
severity: Enum.Severity?,
codeDescription: { href: string }?,
}
},
}
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService:RegisterScriptAnalysisCallback("foo", 1, function(Req: Request): Response
local response = {
diagnostics = {},
}
local lineNo = 1
-- 行ごとに繰り返す
for text, newline in Req.script.Source:gmatch("([^\r\n]*)([\r\n]*)") do
local startIndex, endIndex = string.find(text, "Foo")
if startIndex and endIndex then
table.insert(response.diagnostics, {
range = {
["start"] = {
line = lineNo,
character = startIndex,
},
["end"] = {
line = lineNo,
character = endIndex,
},
},
code = "FooFinder",
message = "ここで Foo が見つかりました!",
severity = Enum.Severity.Warning,
})
end
lineNo = lineNo + #newline:gsub("\n+", "\0%0\0"):gsub(".%z.", "."):gsub("%z", "")
end
return response
end)

UpdateSourceAsync
イールド
プラグインのセキュリティ
ScriptEditorService:UpdateSourceAsync(
script:LuaSourceContainer, callback:function
):()
パラメータ
callback:function
戻り値
()

イベント
TextDocumentDidChange
プラグインのセキュリティ
ScriptEditorService.TextDocumentDidChange(
document:ScriptDocument, changesArray:Variant
パラメータ
changesArray:Variant
コードサンプル
スクリプトエディタサービス.TextDocumentDidChange
--!nocheck
-- コマンドバーで次のコードを実行します
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService.TextDocumentDidChange:Connect(function(scriptDocument, changes)
print("変更されました", scriptDocument, changes)
end)

TextDocumentDidClose
プラグインのセキュリティ
ScriptEditorService.TextDocumentDidClose(oldDocument:ScriptDocument):RBXScriptSignal
パラメータ
oldDocument:ScriptDocument
コードサンプル
ScriptEditorService.TextDocumentDidClose
--!nocheck
-- 次のコードをコマンドバーで実行します
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService.TextDocumentDidClose:Connect(function(scriptDocument)
print("閉じました", scriptDocument)
end)

TextDocumentDidOpen
プラグインのセキュリティ
ScriptEditorService.TextDocumentDidOpen(newDocument:ScriptDocument):RBXScriptSignal
パラメータ
newDocument:ScriptDocument
コードサンプル
ScriptEditorService.TextDocumentDidOpen
--!nocheck
-- Run the following code in the Command Bar
local ScriptEditorService = game:GetService("ScriptEditorService")
ScriptEditorService.TextDocumentDidOpen:Connect(function(scriptDocument)
print("Opened", scriptDocument)
end)

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。