เรียนรู้
Engine Class
TextButton

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
ContentText
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.ContentText:string

Font
ซ่อนอยู่
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.Font:Enum.Font
ตัวอย่างโค้ด
แสดงทุกฟอนต์
local frame = script.Parent
-- สร้าง TextLabel แสดงแต่ละฟอนต์
for _, font in pairs(Enum.Font:GetEnumItems()) do
local textLabel = Instance.new("TextLabel")
textLabel.Name = font.Name
-- ตั้งค่าคุณสมบัติของข้อความ
textLabel.Text = font.Name
textLabel.Font = font
-- คุณสมบัติการเรndering บางอย่าง
textLabel.TextSize = 24
textLabel.TextXAlignment = Enum.TextXAlignment.Left
-- ขนาดของเฟรมให้เท่ากับความสูงของข้อความ
textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextSize)
-- เพิ่มไปยังเฟรมแม่
textLabel.Parent = frame
end
-- จัดเรียงเฟรมในรูปแบบรายการ (ถ้ายังไม่ได้เรียง)
if not frame:FindFirstChildOfClass("UIListLayout") then
local uiListLayout = Instance.new("UIListLayout")
uiListLayout.Parent = frame
end

FontFace
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.FontFace:Font

FontSize
เลิกใช้แล้ว

LineHeight
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.LineHeight:number

LocalizedText
ซ่อนอยู่
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.LocalizedText:string

MaxVisibleGraphemes
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.MaxVisibleGraphemes:number

OpenTypeFeatures
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.OpenTypeFeatures:string

OpenTypeFeaturesError
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.OpenTypeFeaturesError:string

RichText
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.RichText:boolean

Text
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.Text:string
ตัวอย่างโค้ด
แบนเนอร์ที่จางหาย
local TweenService = game:GetService("TweenService")
local textLabel = script.Parent
local content = {
"ยินดีต้อนรับสู่เกมของฉัน!",
"อย่าลืมสนุกสนานนะ!",
"กรุณาให้คำแนะนำ!",
"ให้เกียรติผู้เล่นคนอื่น!",
"อย่าก่อกวนผู้เล่นคนอื่น!",
"ดูที่ร้านค้าด้วย!",
"เคล็ดลับ: อย่าตาย!",
}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local RNG = Random.new()
local fadeIn = TweenService:Create(textLabel, tweenInfo, {
TextTransparency = 0,
})
local fadeOut = TweenService:Create(textLabel, tweenInfo, {
TextTransparency = 1,
})
local lastIndex
while true do
-- ขั้นตอนที่ 0: จางหายก่อนทำอะไร
fadeOut:Play()
task.wait(tweenInfo.Time)
-- ขั้นตอนที่ 1: เลือกเนื้อหาที่ไม่ใช่เนื้อหาที่แสดงล่าสุด
local index
repeat
index = RNG:NextInteger(1, #content)
until lastIndex ~= index
-- ตรวจสอบว่าเราไม่แสดงสิ่งเดิมอีกในครั้งถัดไป
lastIndex = index
-- ขั้นตอนที่ 2: แสดงเนื้อหา
textLabel.Text = content[index]
fadeIn:Play()
task.wait(tweenInfo.Time + 1)
end
อิโมจิในข้อความ
local textLabel = script.Parent
local moods = {
["happy"] = "😃",
["sad"] = "😢",
["neutral"] = "😐",
["tired"] = "😫",
}
while true do
for mood, face in pairs(moods) do
textLabel.Text = "ฉันรู้สึกว่า " .. mood .. "! " .. face
task.wait(1)
end
end

TextBounds
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextBounds:Vector2

TextColor
เลิกใช้แล้ว

TextColor3
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextColor3:Color3
ตัวอย่างโค้ด
ข้อความนับถอยหลัง
-- วางโค้ดนี้ใน LocalScript ภายใน TextLabel/TextButton
local textLabel = script.Parent
-- สีบางอย่างที่เราจะใช้กับ TextColor3
local colorNormal = Color3.new(0, 0, 0) -- สีดำ
local colorSoon = Color3.new(1, 0.5, 0.5) -- สีแดง
local colorDone = Color3.new(0.5, 1, 0.5) -- สีเขียว
-- ลูปตลอดไป
while true do
-- นับถอยหลังจาก 10 ถึง 1
for i = 10, 1, -1 do
-- ตั้งข้อความ
textLabel.Text = "เวลา: " .. i
-- ตั้งค่าสีตามเวลาที่เหลือ
if i > 3 then
textLabel.TextColor3 = colorNormal
else
textLabel.TextColor3 = colorSoon
end
task.wait(1)
end
textLabel.Text = "ไป!"
textLabel.TextColor3 = colorDone
task.wait(2)
end

TextDirection
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextDirection:Enum.TextDirection

TextFits
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextFits:boolean

TextScaled
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextScaled:boolean

TextSize
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextSize:number

TextStrokeColor3
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextStrokeColor3:Color3

TextStrokeTransparency
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextStrokeTransparency:number

TextTransparency
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextTransparency:number

TextTruncate
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextTruncate:Enum.TextTruncate

TextWrap
เลิกใช้แล้ว

TextWrapped
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextWrapped:boolean

TextXAlignment
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextXAlignment:Enum.TextXAlignment

TextYAlignment
อ่านพร้อมๆ กัน
ความสามารถ: UI
TextButton.TextYAlignment:Enum.TextYAlignment

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ