Aller au contenu
— —

ContextActionService

Lier une action à plusieurs touches, avec un bouton tactile automatique.

Aussi appelé BindAction UnbindAction action contextuelle Boutons tactiles SetPosition SetTitle

C’est quoi ?

ContextActionService:BindAction(nom, fonction, creerBouton, touches...) relie une action à des touches clavier et manette. Avec true, un bouton apparaît sur l’écran tactile. UnbindAction retire l’action.

Exemple en Luau
local CAS = game:GetService("ContextActionService")
local function bloquer(nom, etat, entree)
    if etat == Enum.UserInputState.Begin then
        print("Blocage")
    elseif etat == Enum.UserInputState.End then
        print("Fin du blocage")
    end
    return Enum.ContextActionResult.Sink
end
CAS:BindAction("Bloquer", bloquer, true,
    Enum.KeyCode.F, Enum.KeyCode.ButtonL2)

Erreurs fréquentes

  • Oublier de vérifier l’état : la fonction est appelée à l’appui et au relâchement.
Documentation officielle Roblox (en français)

Utilise ContextActionService 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