Kelas Engine
TextButton
*Konten ini diterjemahkan menggunakan AI (Beta) dan mungkin mengandung kesalahan. Untuk melihat halaman ini dalam bahasa Inggris, klik di sini.
Rangkuman
Properti
Referensi API
Properti
Font
Contoh Kode
Tampilkan Semua Font
local frame = script.Parent
-- Buat sebuah TextLabel yang menampilkan setiap font
for _, font in pairs(Enum.Font:GetEnumItems()) do
local textLabel = Instance.new("TextLabel")
textLabel.Name = font.Name
-- Atur properti teks
textLabel.Text = font.Name
textLabel.Font = font
-- Beberapa properti rendering
textLabel.TextSize = 24
textLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Ukuran frame sama dengan tinggi teks
textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextSize)
-- Tambahkan ke frame induk
textLabel.Parent = frame
end
-- Tata letak frame dalam daftar (jika belum dilakukan)
if not frame:FindFirstChildOfClass("UIListLayout") then
local uiListLayout = Instance.new("UIListLayout")
uiListLayout.Parent = frame
endFontSize
Text
Contoh Kode
Spanduk Memudar
local TweenService = game:GetService("TweenService")
local textLabel = script.Parent
local content = {
"Selamat datang di permainan saya!",
"Pastikan untuk bersenang-senang!",
"Silakan beri saran!",
"Bersikap baik kepada pemain lain!",
"Jangan merusak permainan pemain lain!",
"Periksa toko!",
"Tip: Jangan mati!",
}
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
-- Langkah 0: Memudar sebelum melakukan apapun
fadeOut:Play()
task.wait(tweenInfo.Time)
-- Langkah 1: pilih konten yang bukan yang terakhir ditampilkan
local index
repeat
index = RNG:NextInteger(1, #content)
until lastIndex ~= index
-- Pastikan kita tidak menunjukkan hal yang sama lain kali
lastIndex = index
-- Langkah 2: tampilkan konten
textLabel.Text = content[index]
fadeIn:Play()
task.wait(tweenInfo.Time + 1)
endEmoji dalam Teks
local textLabel = script.Parent
local moods = {
["happy"] = "😃",
["sad"] = "😢",
["neutral"] = "😐",
["tired"] = "😫",
}
while true do
for mood, face in pairs(moods) do
textLabel.Text = "Saya merasa " .. mood .. "! " .. face
task.wait(1)
end
endTextColor
TextColor3
Contoh Kode
Teks Hitung Mundur
-- Tempatkan kode ini dalam LocalScript di dalam TextLabel/TextButton
local textLabel = script.Parent
-- Beberapa warna yang akan kita gunakan dengan TextColor3
local colorNormal = Color3.new(0, 0, 0) -- hitam
local colorSoon = Color3.new(1, 0.5, 0.5) -- merah
local colorDone = Color3.new(0.5, 1, 0.5) -- hijau
-- Loop tak terhingga
while true do
-- Hitung mundur dari 10 ke 1
for i = 10, 1, -1 do
-- Atur teks
textLabel.Text = "Waktu: " .. i
-- Atur warna berdasarkan berapa banyak waktu yang tersisa
if i > 3 then
textLabel.TextColor3 = colorNormal
else
textLabel.TextColor3 = colorSoon
end
task.wait(1)
end
textLabel.Text = "AYO!"
textLabel.TextColor3 = colorDone
task.wait(2)
endTextWrap