Clase de motor
TextButton
*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.
Resumen
Propiedades
Referencia API
Propiedades
Font
Muestras de código
Mostrar todas las fuentes
local frame = script.Parent
-- Crear un TextLabel mostrando cada fuente
for _, font in pairs(Enum.Font:GetEnumItems()) do
local textLabel = Instance.new("TextLabel")
textLabel.Name = font.Name
-- Establecer las propiedades del texto
textLabel.Text = font.Name
textLabel.Font = font
-- Algunas propiedades de renderizado
textLabel.TextSize = 24
textLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Dimensionar el marco igual a la altura del texto
textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextSize)
-- Agregar al marco padre
textLabel.Parent = frame
end
-- Organizar los marcos en una lista (si no lo están ya)
if not frame:FindFirstChildOfClass("UIListLayout") then
local uiListLayout = Instance.new("UIListLayout")
uiListLayout.Parent = frame
endFontSize
Text
Muestras de código
Banner Desvanecido
local TweenService = game:GetService("TweenService")
local textLabel = script.Parent
local content = {
"¡Bienvenido a mi juego!",
"¡Asegúrate de divertirte!",
"¡Por favor, haz sugerencias!",
"¡Sé amable con otros jugadores!",
"¡No molestes a otros jugadores!",
"¡Echa un vistazo a la tienda!",
"Consejo: ¡No mueras!",
}
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
-- Paso 0: Desvanecer antes de hacer cualquier cosa
fadeOut:Play()
task.wait(tweenInfo.Time)
-- Paso 1: elegir contenido que no fue el último mostrado
local index
repeat
index = RNG:NextInteger(1, #content)
until lastIndex ~= index
-- Asegúrate de no mostrar lo mismo la próxima vez
lastIndex = index
-- Paso 2: mostrar el contenido
textLabel.Text = content[index]
fadeIn:Play()
task.wait(tweenInfo.Time + 1)
endEmoji en Texto
local textLabel = script.Parent
local moods = {
["happy"] = "😃",
["sad"] = "😢",
["neutral"] = "😐",
["tired"] = "😫",
}
while true do
for mood, face in pairs(moods) do
textLabel.Text = "¡Me siento " .. mood .. "! " .. face
task.wait(1)
end
endTextColor
TextColor3
Muestras de código
Texto de Cuenta Regresiva
-- Coloca este código en un LocalScript dentro de un TextLabel/TextButton
local textLabel = script.Parent
-- Algunos colores que usaremos con TextColor3
local colorNormal = Color3.new(0, 0, 0) -- negro
local colorSoon = Color3.new(1, 0.5, 0.5) -- rojo
local colorDone = Color3.new(0.5, 1, 0.5) -- verde
-- Bucle infinito
while true do
-- Cuenta hacia atrás desde 10 hasta 1
for i = 10, 1, -1 do
-- Establece el texto
textLabel.Text = "Tiempo: " .. i
-- Establece el color basado en cuánto tiempo queda
if i > 3 then
textLabel.TextColor3 = colorNormal
else
textLabel.TextColor3 = colorSoon
end
task.wait(1)
end
textLabel.Text = "¡VAMOS!"
textLabel.TextColor3 = colorDone
task.wait(2)
endTextWrap