學習
引擎類別
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
-- 一些渲染屬性
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
範例程式碼
倒數計時文字
-- 將此代碼放在 TextLabel/TextButton 內的 LocalScript中
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 是我們在美國及其他國家地區的部分註冊與未註冊商標。