Classe de moteur
TextButton
*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.
Résumé
Propriétés
Référence API
Propriétés
Font
Échantillons de code
Afficher toutes les polices
local frame = script.Parent
-- Créer un TextLabel affichant chaque police
for _, font in pairs(Enum.Font:GetEnumItems()) do
local textLabel = Instance.new("TextLabel")
textLabel.Name = font.Name
-- Définir les propriétés du texte
textLabel.Text = font.Name
textLabel.Font = font
-- Certaines propriétés de rendu
textLabel.TextSize = 24
textLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Ajuster la taille du cadre à la hauteur du texte
textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextSize)
-- Ajouter au cadre parent
textLabel.Parent = frame
end
-- Disposer les cadres dans une liste (s'ils ne le sont pas déjà)
if not frame:FindFirstChildOfClass("UIListLayout") then
local uiListLayout = Instance.new("UIListLayout")
uiListLayout.Parent = frame
endFontSize
Text
Échantillons de code
Bannière Fuyante
local TweenService = game:GetService("TweenService")
local textLabel = script.Parent
local content = {
"Bienvenue dans mon jeu!",
"Assurez-vous de vous amuser!",
"Merci de donner des suggestions!",
"Soyez gentil avec les autres joueurs!",
"Ne détruisez pas les autres joueurs!",
"Découvrez le magasin!",
"Conseil : Ne mourrez pas!",
}
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
-- Étape 0 : Fuir avant de faire quoi que ce soit
fadeOut:Play()
task.wait(tweenInfo.Time)
-- Étape 1 : choisir un contenu qui n'était pas le dernier affiché
local index
repeat
index = RNG:NextInteger(1, #content)
until lastIndex ~= index
-- Assurez-vous de ne pas montrer la même chose la prochaine fois
lastIndex = index
-- Étape 2 : montrer le contenu
textLabel.Text = content[index]
fadeIn:Play()
task.wait(tweenInfo.Time + 1)
endÉmoji dans le texte
local textLabel = script.Parent
local moods = {
["happy"] = "😃",
["sad"] = "😢",
["neutral"] = "😐",
["tired"] = "😫",
}
while true do
for mood, face in pairs(moods) do
textLabel.Text = "Je me sens " .. mood .. "! " .. face
task.wait(1)
end
endTextColor
TextColor3
Échantillons de code
Texte de compte à rebours
-- Placez ce code dans un LocalScript à l'intérieur d'un TextLabel/TextButton
local textLabel = script.Parent
-- Certaines couleurs que nous utiliserons avec TextColor3
local colorNormal = Color3.new(0, 0, 0) -- noir
local colorSoon = Color3.new(1, 0.5, 0.5) -- rouge
local colorDone = Color3.new(0.5, 1, 0.5) -- vert
-- Boucle infinie
while true do
-- Comptez à rebours de 10 à 1
for i = 10, 1, -1 do
-- Définir le texte
textLabel.Text = "Temps : " .. i
-- Définir la couleur en fonction du temps restant
if i > 3 then
textLabel.TextColor3 = colorNormal
else
textLabel.TextColor3 = colorSoon
end
task.wait(1)
end
textLabel.Text = "PARTEZ!"
textLabel.TextColor3 = colorDone
task.wait(2)
endTextWrap