Learn
Motor Sınıfı
ScriptDocument
Oluşturulamaz
Çoğaltılmamış

*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.


Özet
Yöntemler
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
Olaylar
SelectionChanged(positionLine: number,positionCharacter: number,anchorLine: number,anchorCharacter: number):RBXScriptSignal
Devralınan Üyeler

API Referansı
Yöntemler
CloseAsync
Bekletir
Eklenti Güvenliği
ScriptDocument:CloseAsync():Tuple
Dönüşler
Kod Örnekleri
ScriptDocument:CloseAsync
`--!nocheck`
`-- Aşağıdaki kodu Komut Çubuğunda çalıştırın`
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
local scriptDocument
`-- İlk açık script belgesini bul`
for _, document in documents do
`-- Komut Çubuğu kapatılamaz, bu yüzden onu seçmeyin`
if not document:IsCommandBar() then
scriptDocument = document
break
end
end
if scriptDocument then
local success, err = scriptDocument:CloseAsync()
if success then
print(`Kapandı {scriptDocument.Name}`)
else
warn(`Kapatılamadı {scriptDocument.Name} çünkü: {err}`)
end
else
print("Açık script yok")
end

EditTextAsync
Bekletir
Eklenti Güvenliği
ScriptDocument:EditTextAsync(
newText:string, startLine:number, startCharacter:number, endLine:number, endCharacter:number
Parametreler
newText:string
startLine:number
startCharacter:number
endLine:number
endCharacter:number
Dönüşler

ForceSetSelectionAsync
Bekletir
Eklenti Güvenliği
ScriptDocument:ForceSetSelectionAsync(
cursorLine:number, cursorCharacter:number, anchorLine:number?, anchorCharacter:number?
Parametreler
cursorLine:number
cursorCharacter:number
anchorLine:number?
Varsayılan değer: "nil"
anchorCharacter:number?
Varsayılan değer: "nil"
Dönüşler
Kod Örnekleri
ScriptDocument:ForceSetSelectionAsync()
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğu'nda çalıştırın
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
-- İmlecin mevcut satırındaki metni alın
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- Tüm metin satırını zorla seçin
local success, err = scriptDocument:ForceSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("Seçim ayarlandı!")
else
print(`Seçimi ayarlamakta başarısız oldu çünkü: {err}`)
end
else
print("Açık script yok")
end

GetLine
Eklenti Güvenliği
ScriptDocument:GetLine(lineIndex:number?):string
Parametreler
lineIndex:number?
Varsayılan değer: "nil"
Dönüşler
Kod Örnekleri
ScriptDocument.SeçimDeğişti ve ScriptDocument:GetLine()
--!nocheck
-- Açıkken Komut Çubuğunda aşağıdaki kodu çalıştırın
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(`Seçilen: Satır {positionLine}, Karakter {positionCharacter}`)
print(`Nokta: Satır {anchorLine}, Karakter {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`Seçilen satır metni: {lineText}`)
end)
else
print("Açık script yok")
end

GetLineCount
Eklenti Güvenliği
ScriptDocument:GetLineCount():number
Dönüşler
Kod Örnekleri
ScriptBelgesi:SatırSayısınıAl()
--!nocheck
-- Aşağıdaki kodu bir komut çubuğunda çalıştırın, bir script açıkken
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(`Scriptin {lineCount} satırı var!`)
else
print("Açık script yok")
end

GetScript
Eklenti Güvenliği
ScriptDocument:GetScript():LuaSourceContainer
Kod Örnekleri
ScriptBelgesi:GetScript()
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğu'nda çalıştırın
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(`Açık olan script: {openScript:GetFullName()}`)
else
print("Açık script yok")
end

GetSelectedText
Eklenti Güvenliği
ScriptDocument:GetSelectedText():string
Dönüşler
Kod Örnekleri
ScriptDocument:SeçiliMetinVarMi() ve :GetSelectedText()
--!nocheck
-- Bir betik açıkken bu kodu Komut Çubuğunda çalıştırın
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(`Mevcut seçili metin: {selectedText}`)
else
print("Şu anda seçili metin yok")
end
end)
else
print("Açık betik yok")
end

GetSelection
Eklenti Güvenliği
ScriptDocument:GetSelection():Tuple
Dönüşler

GetSelectionEnd
Eklenti Güvenliği
ScriptDocument:GetSelectionEnd():Tuple
Dönüşler
Kod Örnekleri
ScriptDocument:GetSelectionStart() ve :GetSelectionEnd()
--!nocheck
-- Bir script açıkken aşağıdaki kodu Komut Çubuğunda çalıştırın
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(`Seçim başlangıcı: Satır {startLine}, Karakter {startCharacter}`)
print(`Seçim sonu: Satır {endLine}, Karakter {endCharacter}`)
else
print("Açık script yok")
end

GetSelectionStart
Eklenti Güvenliği
ScriptDocument:GetSelectionStart():Tuple
Dönüşler
Kod Örnekleri
ScriptDocument:GetSelectionStart() ve :GetSelectionEnd()
--!nocheck
-- Bir script açıkken aşağıdaki kodu Komut Çubuğunda çalıştırın
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(`Seçim başlangıcı: Satır {startLine}, Karakter {startCharacter}`)
print(`Seçim sonu: Satır {endLine}, Karakter {endCharacter}`)
else
print("Açık script yok")
end

GetText
Eklenti Güvenliği
ScriptDocument:GetText(
startLine:number?, startCharacter:number?, endLine:number?, endCharacter:number?
Parametreler
startLine:number?
Varsayılan değer: "nil"
startCharacter:number?
Varsayılan değer: "nil"
endLine:number?
Varsayılan değer: "nil"
endCharacter:number?
Varsayılan değer: "nil"
Dönüşler
Kod Örnekleri
ScriptBelgesi:GetText()
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğunda çalıştırın
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(`Script içeriği: {text}`)
else
print("Açık hiçbir script yok")
end

GetViewport
Eklenti Güvenliği
ScriptDocument:GetViewport():Tuple
Dönüşler
Kod Örnekleri
ScriptBelgesi: Görünüm
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğunda çalıştırın
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(`Şu anda {firstLine} ile {lastLine} arası satırlar görüntüleniyor`)
else
print("Açık script yok")
end

HasSelectedText
Eklenti Güvenliği
ScriptDocument:HasSelectedText():boolean
Dönüşler
Kod Örnekleri
ScriptDocument:SeçiliMetinVarMi() ve :GetSelectedText()
--!nocheck
-- Bir betik açıkken bu kodu Komut Çubuğunda çalıştırın
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(`Mevcut seçili metin: {selectedText}`)
else
print("Şu anda seçili metin yok")
end
end)
else
print("Açık betik yok")
end

IsCommandBar
Eklenti Güvenliği
ScriptDocument:IsCommandBar():boolean
Dönüşler
Kod Örnekleri
ScriptDocument:Komut Çubuğu mu?
--!nocheck
-- Aşağıdaki kodu Komut Çubuğunda çalıştırın
local ScriptEditorService = game:GetService("ScriptEditorService")
local documents = ScriptEditorService:GetScriptDocuments()
for _, document in documents do
if document:IsCommandBar() then
print("Komut çubuğu belgesi:", document)
end
end

MultiEditTextAsync
Bekletir
Eklenti Güvenliği
ScriptDocument:MultiEditTextAsync(edits:{any}):Tuple
Parametreler
edits:{any}
Dönüşler

RequestSetSelectionAsync
Bekletir
Eklenti Güvenliği
ScriptDocument:RequestSetSelectionAsync(
cursorLine:number, cursorCharacter:number, anchorLine:number?, anchorCharacter:number?
Parametreler
cursorLine:number
cursorCharacter:number
anchorLine:number?
Varsayılan değer: "nil"
anchorCharacter:number?
Varsayılan değer: "nil"
Dönüşler
Kod Örnekleri
ScriptDocument:RequestSetSelectionAsync()
--!nocheck
-- Aşağıdaki kodu bir script açıkken Komut Çubuğunda çalıştırın
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
-- İmlecin mevcut satırındaki metni alın
local cursorLine = scriptDocument:GetSelection()
local lineText = scriptDocument:GetLine(cursorLine)
-- Tüm metin satırını seçmek için zorlayın
local success, err = scriptDocument:RequestSetSelectionAsync(cursorLine, 1, cursorLine, #lineText + 1)
if success then
print("Seçim ayarlandı!")
else
print(`Seçim ayarlanamadı çünkü: {err}`)
end
else
print("Açık script yok")
end

Olaylar
SelectionChanged
Eklenti Güvenliği
ScriptDocument.SelectionChanged(
positionLine:number, positionCharacter:number, anchorLine:number, anchorCharacter:number
Parametreler
positionLine:number
positionCharacter:number
anchorLine:number
anchorCharacter:number
Kod Örnekleri
ScriptDocument.SeçimDeğişti ve ScriptDocument:GetLine()
--!nocheck
-- Açıkken Komut Çubuğunda aşağıdaki kodu çalıştırın
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(`Seçilen: Satır {positionLine}, Karakter {positionCharacter}`)
print(`Nokta: Satır {anchorLine}, Karakter {anchorCharacter}`)
local lineText = scriptDocument:GetLine(positionLine)
print(`Seçilen satır metni: {lineText}`)
end)
else
print("Açık script yok")
end

ViewportChanged
Eklenti Güvenliği
ScriptDocument.ViewportChanged(
startLine:number, endLine:number
Parametreler
startLine:number
endLine:number
Kod Örnekleri
ScriptDocument.ViewportChanged'e Bağlanıyor
--!nocheck
--[[
Çalıştırmak için:
1. Çıkış görünümünün açık olduğundan emin olun
2. Aşağıdaki kodu Komut Çubuğu'nda çalıştırın
3. Açılan Script penceresinde yukarı ve aşağı kaydırın
ViewportChanged olayından yazdırma ifadeleri Çıkış'ta görünecektir
]]
local Workspace = game:GetService("Workspace")
local ScriptEditorService = game:GetService("ScriptEditorService")
-- Birçok satırı kapsayan metin oluşturun
local dummyText = string.rep("-- Dummy Text\n", 60)
-- Dummy metni içeren bir script oluşturun ve açın
local otherScript = Instance.new("Script")
otherScript.Source = dummyText
otherScript.Parent = Workspace
local success, err = ScriptEditorService:OpenScriptDocumentAsync(otherScript)
if not success then
warn(`Script açılmadı çünkü: {err}`)
return
end
-- Açılan script'e referans alın
local scriptDocument = ScriptEditorService:FindScriptDocument(otherScript)
local function onViewportChanged(startLine: number, endLine: number)
print(`Script Görüntü Alanı Değişti - başlangıç Satırı: {startLine}, bitiş Satırı: {endLine}`)
end
-- Yukarıdaki fonksiyonu görüntü alanının güncellenmiş başlangıç ve bitiş satırını yazdıracak şekilde ViewportChanged olayına bağlayın
scriptDocument.ViewportChanged:Connect(onViewportChanged)

©2026 Roblox Corporation. Roblox, the Roblox logo and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.