When Pressed
Fires the instant the player presses the UI button down, before they let go.
Introduction
When Pressed is an event in the Button group of UI Events. It fires the instant the player presses the button down, before they let go. When it fires, the event hands the player to your script, so you know exactly who interacted. Like every event, it does nothing by itself. It waits for the right moment, then runs all the actions connected to it. Button gestures come in threes: this event fires when the finger goes down, When Release fires when it lifts, and When Clicked confirms a complete press-and-release on the button. To build the button itself - labels, icons, and click states - open the UI Button guide, and for the panel that hosts it see Character UI . When Pressed event in the UI Editor Image The When Pressed event in the UI Editor. caption When Button is Pressed, fires while the player is holding a UI button down. This event is attached to: the Button widget inside a UI panel. It belongs to the "Button" group because its home is a UI widget, not a 3D object in the game world.
Parameters
Player the player who is pressing the button down Parameter Description
How to Access
How to Access - When Pressed
Example
When Pressed event with Set Color and Play Audio actions when-button-is-pressed-example.webp Example: the button adds a tiny jump height boost while the player holds it. caption
How to Use
Select the Button element and open its properties, then find its component block. Check that the When Pressed event is listed in the block; if it is hidden, press the three dots (...) at the top right of the block and check it in the pop-up list. Press Scripts + next to When Pressed , then add the actions that should run when the event fires: what should begin the moment the button goes down, such as a sound or a pressed visual. Pair it with When Released when something should stop or reverse when the button is let go. Press Play and press the button down to confirm the event fires on the press, not on the release.
Common Uses
Play press feedback like sounds or color changes Charge actions while the button is held Start continuous actions that stop on release
Tip
When Pressed runs once per press. For actions that should repeat while the button stays down, start them here and stop them with When Release.