31. Filter completion events carefully
OnVideoEnd and OnMusicEnd are useful for natural completion. They are not universal notifications for every stop, seek, skip, replacement or loop. Test the exact route you intend to use.
func on_music_end(event: Dictionary = {}) -> Variant:
if event.get("musicAssetId", "") != "opening_theme":
return false
await ShowMessage({"text": "The room falls quiet.",
"duration": 2.2})
return true1. Subscribe the script to OnMusicEnd.
2. Use a short, non-looping track for the first test.
3. Let it finish naturally, then repeat the test with Pause/Resume and with Stop.
4. Confirm that the response only runs when the intended completion route occurs.
Visual scripting also has dedicated On Video End and On Music End entry nodes with optional asset filtering. The broad On Event picker does not include those two names in this build. Avoid giving a graph two equivalent completion routes that each grant the same reward.
A returned false value from a listener is not a global "cancel this event" instruction. Keep listeners independent and do not use undocumented return-value conventions as an event priority system.
