When Value is Changed
Fires when the player switches the toggle on or off.
Introduction
When Value is Changed is an event in the Toggle group of UI Events. It fires when the player switches the toggle on or off. Like every event, it does nothing by itself. It waits for the right moment, then runs all the actions connected to it. Toggles are the switches of your interface: this event fires with the new state every time the player flips it, which suits settings panels like music on/off or hints on/off. Build the element with the UI Toggle guide, and for continuous values instead of two states use When Slider is Changed . When Value is Changed event in the UI Editor Image The When Value is Changed event in the UI Editor. caption
Parameters
None This event has no parameters. The event fires on its own and everything you need is the object running this script. Parameter Description
How to Access
How to Access - When Value is Changed
How to Use
Select the toggle element and open its properties, then find its component block. Check that the When Value is Changed 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 Value is Changed , then add the actions that should run when the event fires: both states of the toggle, on and off, so nothing gets stuck. Read the toggle’s current value in the connected actions to know which state it switched to. Press Play and flip the toggle a few times to confirm both directions work.
Example
When Value is Changed event with a Set Music command when-toggle-is-changed-example.webp Example: the camera switches to first person when the toggle is on, and back to free camera when it is off. caption
Common Uses
Sound and music on off switches Visual quality or effect switches Any setting with two states
Tip
Always handle both directions. A toggle that only handles one state leaves the world in the wrong mode when the player switches it back.