배우기
엔진 클래스
TextBox

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


코드 샘플
텍스트박스 비밀 단어
-- 이 코드를 텍스트박스 안의 LocalScript에 배치하세요
local textBox = script.Parent
local secretWord = "roblox"
local colorNormal = Color3.new(1, 1, 1) -- 흰색
local colorWrong = Color3.new(1, 0, 0) -- 빨간색
local colorCorrect = Color3.new(0, 1, 0) -- 초록색
-- textBox의 상태 초기화
textBox.ClearTextOnFocus = true
textBox.Text = ""
textBox.Font = Enum.Font.Code
textBox.PlaceholderText = "비밀 단어는 무엇인가요?"
textBox.BackgroundColor3 = colorNormal
local function onFocused()
textBox.BackgroundColor3 = colorNormal
end
local function onFocusLost(enterPressed, _inputObject)
if enterPressed then
local guess = textBox.Text
if guess == secretWord then
textBox.Text = "접근 허가됨"
textBox.BackgroundColor3 = colorCorrect
else
textBox.Text = "접근 거부됨"
textBox.BackgroundColor3 = colorWrong
end
else
-- 플레이어가 Enter를 누르지 않고 편집을 중지했습니다.
textBox.Text = ""
textBox.BackgroundColor3 = colorNormal
end
end
textBox.FocusLost:Connect(onFocusLost)
textBox.Focused:Connect(onFocused)

API 참조
속성
ClearTextOnFocus
병렬 읽기
기능: UI
TextBox.ClearTextOnFocus:boolean

ContentText
읽기 전용
복제되지 않음
병렬 읽기
기능: UI
TextBox.ContentText:string

CursorPosition
병렬 읽기
기능: UI
TextBox.CursorPosition:number
코드 샘플
텍스트 박스 선택
local textBox = script.Parent
local function showSelection()
if textBox.CursorPosition == -1 or textBox.SelectionStart == -1 then
print("선택 없음")
else
local selectedText = string.sub(
textBox.Text,
math.min(textBox.CursorPosition, textBox.SelectionStart),
math.max(textBox.CursorPosition, textBox.SelectionStart)
)
print('선택된 내용은:"', selectedText, '"입니다')
end
end
textBox:GetPropertyChangedSignal("CursorPosition"):Connect(showSelection)
textBox:GetPropertyChangedSignal("SelectionStart"):Connect(showSelection)

Font
숨김
복제되지 않음
병렬 읽기
기능: UI
TextBox.Font:Enum.Font

FontFace
병렬 읽기
기능: UI
TextBox.FontFace:Font

FontSize
사용되지 않음

LineHeight
병렬 읽기
기능: UI
TextBox.LineHeight:number

MaxVisibleGraphemes
병렬 읽기
기능: UI
TextBox.MaxVisibleGraphemes:number

MultiLine
병렬 읽기
기능: UI
TextBox.MultiLine:boolean

OpenTypeFeatures
병렬 읽기
기능: UI
TextBox.OpenTypeFeatures:string

OpenTypeFeaturesError
읽기 전용
복제되지 않음
병렬 읽기
기능: UI
TextBox.OpenTypeFeaturesError:string

PlaceholderColor3
병렬 읽기
기능: UI
TextBox.PlaceholderColor3:Color3

PlaceholderText
병렬 읽기
기능: UI
TextBox.PlaceholderText:string

RichText
병렬 읽기
기능: UI
TextBox.RichText:boolean

SelectionStart
병렬 읽기
기능: UI
TextBox.SelectionStart:number
코드 샘플
텍스트 박스 선택
local textBox = script.Parent
local function showSelection()
if textBox.CursorPosition == -1 or textBox.SelectionStart == -1 then
print("선택 없음")
else
local selectedText = string.sub(
textBox.Text,
math.min(textBox.CursorPosition, textBox.SelectionStart),
math.max(textBox.CursorPosition, textBox.SelectionStart)
)
print('선택된 내용은:"', selectedText, '"입니다')
end
end
textBox:GetPropertyChangedSignal("CursorPosition"):Connect(showSelection)
textBox:GetPropertyChangedSignal("SelectionStart"):Connect(showSelection)

ShowNativeInput
병렬 읽기
기능: UI
TextBox.ShowNativeInput:boolean

Text
병렬 읽기
기능: UI
TextBox.Text:string

TextBounds
읽기 전용
복제되지 않음
병렬 읽기
기능: UI
TextBox.TextBounds:Vector2

TextColor
사용되지 않음

TextColor3
병렬 읽기
기능: UI
TextBox.TextColor3:Color3
코드 샘플
모음 탐지기
local textBox = script.Parent
local function hasVowels(str)
return str:lower():find("[aeiou]")
end
local function onTextChanged()
local text = textBox.Text
-- 모음 체크
if hasVowels(text) then
textBox.TextColor3 = Color3.new(0, 0, 0) -- 검정색
else
textBox.TextColor3 = Color3.new(1, 0, 0) -- 빨간색
end
end
textBox:GetPropertyChangedSignal("Text"):Connect(onTextChanged)

TextDirection
병렬 읽기
기능: UI
TextBox.TextDirection:Enum.TextDirection

TextEditable
병렬 읽기
기능: UI
TextBox.TextEditable:boolean

TextFits
읽기 전용
복제되지 않음
병렬 읽기
기능: UI
TextBox.TextFits:boolean

TextScaled
병렬 읽기
기능: UI
TextBox.TextScaled:boolean

TextSize
병렬 읽기
기능: UI
TextBox.TextSize:number

TextStrokeColor3
병렬 읽기
기능: UI
TextBox.TextStrokeColor3:Color3

TextStrokeTransparency
병렬 읽기
기능: UI
TextBox.TextStrokeTransparency:number

TextTransparency
병렬 읽기
기능: UI
TextBox.TextTransparency:number

TextTruncate
병렬 읽기
기능: UI
TextBox.TextTruncate:Enum.TextTruncate

TextWrap
사용되지 않음

TextWrapped
병렬 읽기
기능: UI
TextBox.TextWrapped:boolean

TextXAlignment
병렬 읽기
기능: UI
TextBox.TextXAlignment:Enum.TextXAlignment

TextYAlignment
병렬 읽기
기능: UI
TextBox.TextYAlignment:Enum.TextYAlignment

메서드
CaptureFocus
기능: UI
TextBox:CaptureFocus():()
반환
()
코드 샘플
텍스트박스 포커스 잡기
local UserInputService = game:GetService("UserInputService")
local textBox = script.Parent
local input = UserInputService.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Q then
textBox:CaptureFocus()
end
end)

IsFocused
기능: UI
TextBox:IsFocused():boolean
반환

ReleaseFocus
기능: UI
TextBox:ReleaseFocus(submitted:boolean):()
매개 변수
submitted:boolean
기본값: false
반환
()
코드 샘플
텍스트 박스 포커스 해제
local UserInputService = game:GetService("UserInputService")
local textBox = script.Parent
local input = UserInputService.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Escape and textBox.IsFocused then
textBox:ReleaseFocus()
end
end)

이벤트
Focused
기능: UI
TextBox.Focused():RBXScriptSignal
코드 샘플
텍스트박스 포커스
local textBox = script.Parent
textBox.Focused:Connect(function()
print("포커스가 맞춰졌습니다!")
end)
textBox.FocusLost:Connect(function()
print("포커스가 잃었습니다!")
end)

FocusLost
기능: UI
TextBox.FocusLost(
enterPressed:boolean, inputThatCausedFocusLoss:InputObject
매개 변수
enterPressed:boolean
inputThatCausedFocusLoss:InputObject
코드 샘플
텍스트박스 포커스
local textBox = script.Parent
textBox.Focused:Connect(function()
print("포커스가 맞춰졌습니다!")
end)
textBox.FocusLost:Connect(function()
print("포커스가 잃었습니다!")
end)
포커스 손실
local textBox = script.Parent
local function onFocusLost(enterPressed, inputThatCausedFocusLost)
if enterPressed then
print("플레이어가 Enter를 눌렀습니다")
else
print("플레이어가", inputThatCausedFocusLost.KeyCode를 눌렀습니다)
end
end
textBox.FocusLost:Connect(onFocusLost)
텍스트박스.포커스잃음1
local gui = script.Parent
local textBox = gui.TextBox
local function focusLost(enterPressed)
if enterPressed then
print("포커스가 잃어버렸습니다. Enter가 눌렸기 때문입니다!")
else
print("Enter가 눌리지 않고 포커스를 잃었습니다")
end
end
textBox.FocusLost:Connect(focusLost)

ReturnPressedFromOnScreenKeyboard
기능: UI
TextBox.ReturnPressedFromOnScreenKeyboard():RBXScriptSignal

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