Lớp công cụ
TextButton
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tóm Tắt
Thuộc Tính
Tài Liệu Tham Khảo API
Thuộc Tính
Font
Mẫu mã
Hiển Thị Tất Cả Phông Chữ
local frame = script.Parent
-- Tạo một TextLabel hiển thị mỗi phông chữ
for _, font in pairs(Enum.Font:GetEnumItems()) do
local textLabel = Instance.new("TextLabel")
textLabel.Name = font.Name
-- Đặt thuộc tính văn bản
textLabel.Text = font.Name
textLabel.Font = font
-- Một số thuộc tính hiển thị
textLabel.TextSize = 24
textLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Đặt kích thước của khung bằng chiều cao của văn bản
textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextSize)
-- Thêm vào khung cha
textLabel.Parent = frame
end
-- Sắp xếp các khung thành một danh sách (nếu chúng chưa có sẵn)
if not frame:FindFirstChildOfClass("UIListLayout") then
local uiListLayout = Instance.new("UIListLayout")
uiListLayout.Parent = frame
endFontSize
Text
Mẫu mã
Bảng Hiện Ngang Mờ
local TweenService = game:GetService("TweenService")
local textLabel = script.Parent
local content = {
"Chào mừng bạn đến với trò chơi của tôi!",
"Hãy chắc chắn rằng bạn vui vẻ!",
"Xin vui lòng đưa ra đề xuất!",
"Hãy thân thiện với các người chơi khác!",
"Đừng quấy rối các người chơi khác!",
"Hãy kiểm tra tiệm!",
"Mẹo: Đừng chết!",
}
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
-- Bước 0: Làm mờ trước khi làm bất cứ điều gì
fadeOut:Play()
task.wait(tweenInfo.Time)
-- Bước 1: chọn nội dung mà không phải là cái đã hiển thị lần trước
local index
repeat
index = RNG:NextInteger(1, #content)
until lastIndex ~= index
-- Đảm bảo chúng ta không hiển thị cùng một thứ lần sau
lastIndex = index
-- Bước 2: hiển thị nội dung
textLabel.Text = content[index]
fadeIn:Play()
task.wait(tweenInfo.Time + 1)
endBiểu tượng cảm xúc trong văn bản
local textLabel = script.Parent
local moods = {
["happy"] = "😃",
["sad"] = "😢",
["neutral"] = "😐",
["tired"] = "😫",
}
while true do
for mood, face in pairs(moods) do
textLabel.Text = "Tôi cảm thấy " .. mood .. "! " .. face
task.wait(1)
end
endTextColor
TextColor3
Mẫu mã
Văn bản đếm ngược
-- Đặt mã này trong một LocalScript bên trong một TextLabel/TextButton
local textLabel = script.Parent
-- Một số màu chúng ta sẽ sử dụng với TextColor3
local colorNormal = Color3.new(0, 0, 0) -- đen
local colorSoon = Color3.new(1, 0.5, 0.5) -- đỏ
local colorDone = Color3.new(0.5, 1, 0.5) -- xanh
-- Lặp vô hạn
while true do
-- Đếm ngược từ 10 đến 1
for i = 10, 1, -1 do
-- Đặt văn bản
textLabel.Text = "Thời gian: " .. i
-- Đặt màu dựa trên thời gian còn lại
if i > 3 then
textLabel.TextColor3 = colorNormal
else
textLabel.TextColor3 = colorSoon
end
task.wait(1)
end
textLabel.Text = "Đi!"
textLabel.TextColor3 = colorDone
task.wait(2)
endTextWrap