Skip to reading
Progress Bars, Hints & Journals

6. Change a bar with an action

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

For an unbound meter, use Change GUI Element Property. This is the simplest first test: a Button changes one element’s current value.

1. Add a Button beside the Progress Bar.

2. Open its Events tab. Choose Change GUI Element Property for Click.

3. Set GUI to progress_lab, Element to power_bar, Property to value and To to 50.

4. Run the game and press the Button. The meter should become half full when Maximum is 100.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    await ChangeGUIElementProperty({
        "guiId": "progress_lab",
        "elementId": "power_bar",
        "property": "value",
        "value": 50
    })
    return true

This is a complete GDScript record for the same operation. Apply it, then assign the record to the intended event or script-running action. The shared action also exists in action lists and visual scripting.

Use this value-based method for an unbound meter. If variable is set on the element, update that variable instead; the next dynamic refresh reads it and can replace a direct value change.

Page 11 of 53Permalink
Go to page