Apprendre
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éférence API
Propriétés
ContentText
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : UI
TextButton.ContentText:string

Font
Caché
Non répliqué
Lecture parallèle
Capacités : UI
TextButton.Font:Enum.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
end

FontFace
Lecture parallèle
Capacités : UI
TextButton.FontFace:Font

FontSize
Déprécié

LineHeight
Lecture parallèle
Capacités : UI
TextButton.LineHeight:number

LocalizedText
Caché
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : UI
TextButton.LocalizedText:string

MaxVisibleGraphemes
Lecture parallèle
Capacités : UI
TextButton.MaxVisibleGraphemes:number

OpenTypeFeatures
Lecture parallèle
Capacités : UI
TextButton.OpenTypeFeatures:string

OpenTypeFeaturesError
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : UI
TextButton.OpenTypeFeaturesError:string

RichText
Lecture parallèle
Capacités : UI
TextButton.RichText:boolean

Text
Lecture parallèle
Capacités : UI
TextButton.Text:string
É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
end

TextBounds
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : UI
TextButton.TextBounds:Vector2

TextColor
Déprécié

TextColor3
Lecture parallèle
Capacités : UI
TextButton.TextColor3:Color3
É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)
end

TextDirection
Lecture parallèle
Capacités : UI
TextButton.TextDirection:Enum.TextDirection

TextFits
Lecture uniquement
Non répliqué
Lecture parallèle
Capacités : UI
TextButton.TextFits:boolean

TextScaled
Lecture parallèle
Capacités : UI
TextButton.TextScaled:boolean

TextSize
Lecture parallèle
Capacités : UI
TextButton.TextSize:number

TextStrokeColor3
Lecture parallèle
Capacités : UI
TextButton.TextStrokeColor3:Color3

TextStrokeTransparency
Lecture parallèle
Capacités : UI
TextButton.TextStrokeTransparency:number

TextTransparency
Lecture parallèle
Capacités : UI
TextButton.TextTransparency:number

TextTruncate
Lecture parallèle
Capacités : UI
TextButton.TextTruncate:Enum.TextTruncate

TextWrap
Déprécié

TextWrapped
Lecture parallèle
Capacités : UI
TextButton.TextWrapped:boolean

TextXAlignment
Lecture parallèle
Capacités : UI
TextButton.TextXAlignment:Enum.TextXAlignment

TextYAlignment
Lecture parallèle
Capacités : UI
TextButton.TextYAlignment:Enum.TextYAlignment

©2026 Société Roblox. Roblox, le logo Roblox et Powering Imagination font partie de nos marques déposées aux États-Unis et dans d'autres pays.