배우기
엔진 클래스
ScriptDocument
만들 수 없음
복제되지 않음

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.


요약
메서드
EditTextAsync(newText: string,startLine: number,startCharacter: number,endLine: number,endCharacter: number):Tuple
ForceSetSelectionAsync(cursorLine: number,cursorCharacter: number,anchorLine: number?,anchorCharacter: number?):Tuple
GetLine(lineIndex: number?):string
GetText(startLine: number?,startCharacter: number?,endLine: number?,endCharacter: number?):string
RequestSetSelectionAsync(cursorLine: number,cursorCharacter: number,anchorLine: number?,anchorCharacter: number?):Tuple
이벤트
SelectionChanged(positionLine: number,positionCharacter: number,anchorLine: number,anchorCharacter: number):RBXScriptSignal
상속된 멤버

API 참조
메서드
CloseAsync
생성
플러그인 보안
ScriptDocument:CloseAsync():Tuple
반환
코드 샘플
스크립트문서: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

EditTextAsync
생성
플러그인 보안
ScriptDocument:EditTextAsync(
newText:string, startLine:number, startCharacter:number, endLine:number, endCharacter:number
매개 변수
newText:string
startLine:number
startCharacter:number
endLine:number
endCharacter:number
반환

ForceSetSelectionAsync
생성
플러그인 보안
ScriptDocument:ForceSetSelectionAsync(
cursorLine:number, cursorCharacter:number, anchorLine:number?, anchorCharacter:number?
매개 변수
cursorLine:number
cursorCharacter:number
anchorLine:number?
기본값: "nil"
anchorCharacter:number?
기본값: "nil"
반환
코드 샘플
스크립트문서:ForceSetSelectionAsync()
--!nocheck
-- 스크립트가 열려 있는 동안 명령줄에서 다음 코드를 실행합니다.
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
-- 커서의 현재 줄에 있는 텍스트를 가져옵니다.
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- 전체 줄의 텍스트를 강제로 선택합니다.
local success, err = scriptDocument:ForceSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("선택이 설정되었습니다!")
else
print(`선택 설정에 실패했습니다: {err}`)
end
else
print("열려 있는 스크립트가 없습니다.")
end

GetLine
플러그인 보안
ScriptDocument:GetLine(lineIndex:number?):string
매개 변수
lineIndex:number?
기본값: "nil"
반환
코드 샘플
스크립트문서.SelectionChanged 및 스크립트문서:GetLine()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하십시오.
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function(positionLine, positionCharacter, anchorLine, anchorCharacter)
print(`선택됨: 줄 {positionLine}, 문자 {positionCharacter}`)
print(`앵커: 줄 {anchorLine}, 문자 {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`선택된 줄 텍스트: {lineText}`)
end)
else
print("열려 있는 스크립트가 없습니다.")
end

GetLineCount
플러그인 보안
ScriptDocument:GetLineCount():number
반환
코드 샘플
스크립트 문서: 줄 수 가져오기
--!nocheck
-- 스크립트가 열려 있는 동안 명령줄에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local lineCount = scriptDocument:GetLineCount()
print(`스크립트에는 {lineCount} 줄이 있습니다!`)
else
print("열려 있는 스크립트가 없습니다")
end

GetScript
플러그인 보안
ScriptDocument:GetScript():LuaSourceContainer
코드 샘플
스크립트 문서 가져오기
--!nocheck
-- 스크립트가 열려 있는 동안 명령 입력줄에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local openScript = scriptDocument:GetScript()
print(`현재 열려 있는 스크립트: {openScript:GetFullName()}`)
else
print("열려 있는 스크립트가 없습니다")
end

GetSelectedText
플러그인 보안
ScriptDocument:GetSelectedText():string
반환
코드 샘플
스크립트 문서: 선택된 텍스트가 있습니까() 및 :선택된 텍스트 가져오기()
--!nocheck
-- 스크립트가 열려 있는 동안 명령줄에서 다음 코드를 실행합니다.
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function()
if scriptDocument:HasSelectedText() then
local selectedText = scriptDocument:GetSelectedText()
print(`현재 선택된 텍스트: {selectedText}`)
else
print("현재 선택된 텍스트가 없습니다")
end
end)
else
print("열려 있는 스크립트가 없습니다")
end

GetSelection
플러그인 보안
ScriptDocument:GetSelection():Tuple
반환

GetSelectionEnd
플러그인 보안
ScriptDocument:GetSelectionEnd():Tuple
반환
코드 샘플
ScriptDocument:GetSelectionStart() 및 :GetSelectionEnd()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local startLine, startCharacter = scriptDocument:GetSelectionStart()
local endLine, endCharacter = scriptDocument:GetSelectionEnd()
print(`Selection start: Line {startLine}, Char {startCharacter}`)
print(`Selection end: Line {endLine}, Char {endCharacter}`)
else
print("열려 있는 스크립트가 없습니다")
end

GetSelectionStart
플러그인 보안
ScriptDocument:GetSelectionStart():Tuple
반환
코드 샘플
ScriptDocument:GetSelectionStart() 및 :GetSelectionEnd()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local startLine, startCharacter = scriptDocument:GetSelectionStart()
local endLine, endCharacter = scriptDocument:GetSelectionEnd()
print(`Selection start: Line {startLine}, Char {startCharacter}`)
print(`Selection end: Line {endLine}, Char {endCharacter}`)
else
print("열려 있는 스크립트가 없습니다")
end

GetText
플러그인 보안
ScriptDocument:GetText(
startLine:number?, startCharacter:number?, endLine:number?, endCharacter:number?
매개 변수
startLine:number?
기본값: "nil"
startCharacter:number?
기본값: "nil"
endLine:number?
기본값: "nil"
endCharacter:number?
기본값: "nil"
반환
코드 샘플
스크립트문서:텍스트가져오기()
--!nocheck
-- 스크립트가 열려 있을 때 명령 입력줄에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local text = scriptDocument:GetText()
print(`스크립트 내용: {text}`)
else
print("열려 있는 스크립트가 없습니다")
end

GetViewport
플러그인 보안
ScriptDocument:GetViewport():Tuple
반환
코드 샘플
스크립트문서:뷰포트가져오기
--!nocheck
-- 스크립트가 열려 있는 동안 명령 바에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
local firstLine, lastLine = scriptDocument:GetViewport()
print(`현재 보고 있는 줄 {firstLine} 부터 {lastLine}`)
else
print("열려 있는 스크립트가 없습니다")
end

HasSelectedText
플러그인 보안
ScriptDocument:HasSelectedText():boolean
반환
코드 샘플
스크립트 문서: 선택된 텍스트가 있습니까() 및 :선택된 텍스트 가져오기()
--!nocheck
-- 스크립트가 열려 있는 동안 명령줄에서 다음 코드를 실행합니다.
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function()
if scriptDocument:HasSelectedText() then
local selectedText = scriptDocument:GetSelectedText()
print(`현재 선택된 텍스트: {selectedText}`)
else
print("현재 선택된 텍스트가 없습니다")
end
end)
else
print("열려 있는 스크립트가 없습니다")
end

IsCommandBar
플러그인 보안
ScriptDocument:IsCommandBar():boolean
반환
코드 샘플
스크립트 문서:IsCommandBar()
--!nocheck
-- 다음 코드를 명령어 바에서 실행합니다.
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if document:IsCommandBar() then
print("명령어 바 문서:", document)
end
end

MultiEditTextAsync
생성
플러그인 보안
ScriptDocument:MultiEditTextAsync(edits:{any}):Tuple
매개 변수
edits:{any}
반환

RequestSetSelectionAsync
생성
플러그인 보안
ScriptDocument:RequestSetSelectionAsync(
cursorLine:number, cursorCharacter:number, anchorLine:number?, anchorCharacter:number?
매개 변수
cursorLine:number
cursorCharacter:number
anchorLine:number?
기본값: "nil"
anchorCharacter:number?
기본값: "nil"
반환
코드 샘플
스크립트문서:RequestSetSelectionAsync()
--!nocheck
-- 스크립트가 열려 있는 동안 명령줄에서 다음 코드를 실행하세요
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
-- 커서의 현재 줄의 텍스트 가져오기
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- 텍스트의 전체 줄 선택 강제 설정
local success, err = scriptDocument:RequestSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("선택이 설정되었습니다!")
else
print(`선택 설정 실패: {err}`)
end
else
print("열려 있는 스크립트가 없습니다")
end

이벤트
SelectionChanged
플러그인 보안
ScriptDocument.SelectionChanged(
positionLine:number, positionCharacter:number, anchorLine:number, anchorCharacter:number
매개 변수
positionLine:number
positionCharacter:number
anchorLine:number
anchorCharacter:number
코드 샘플
스크립트문서.SelectionChanged 및 스크립트문서:GetLine()
--!nocheck
-- 스크립트가 열려 있는 동안 Command Bar에서 다음 코드를 실행하십시오.
local ScriptEditorService = game:GetService("ScriptEditorService")
local function getFirstOpenDocument()
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if not document:IsCommandBar() then
return document
end
end
return nil
end
local scriptDocument = getFirstOpenDocument()
if scriptDocument then
scriptDocument.SelectionChanged:Connect(function(positionLine, positionCharacter, anchorLine, anchorCharacter)
print(`선택됨: 줄 {positionLine}, 문자 {positionCharacter}`)
print(`앵커: 줄 {anchorLine}, 문자 {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`선택된 줄 텍스트: {lineText}`)
end)
else
print("열려 있는 스크립트가 없습니다.")
end

ViewportChanged
플러그인 보안
ScriptDocument.ViewportChanged(
startLine:number, endLine:number
매개 변수
startLine:number
endLine:number
코드 샘플
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)

©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.