Aller au contenu
— —

string.find

Chercher un mot ou un motif dans un texte.

Aussi appelé string.match chercher dans un texte motifs

C’est quoi ?

texte:find("mot", 1, true) renvoie la position du mot, ou nil. Le true désactive les motifs spéciaux. texte:match("%d+") extrait le premier nombre.

Exemple en Luau
local nom = "Etape12"
local numero = tonumber(nom:match("%d+"))
print(numero)  -- 12
if nom:find("Etape", 1, true) then
    print("C’est un checkpoint")
end

Erreurs fréquentes

  • Chercher un texte contenant . ou - sans le true : ce sont des caractères spéciaux de motif.
Documentation officielle Roblox (en français)

Utilise string.find dans ton propre jeu

Avec LearnBlox, tu crées ton jeu Roblox pas à pas, directement dans Roblox Studio. La formation « Les bases » est gratuite et Bloxi t’aide quand tu bloques.

Commencer gratuitement