How do I use audio busses with hsliders?

Godot Version



I have a master volume bus that I can change the volume with in the settings, and I made a music bus, but what do I do for the code to make the music hslider value correlate to the music bus? I am new to coding and for the master volume bus I used the AudioServer.set_bus_volume_db(0,value) code from a tutorial.


You would do the same thing you did for the Master bus. The difference is you would use 1 for your index instead of 0. Alternatively, you could allow godot to get the index you want based on the bus you are trying to get. Here is an example of this

AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Music"), value)

as you see instead of passing in a 0 or 1 or 2 etc for the index, I am instead calling the function AudioServer.get_bus_index(“Music”). The string I pass in of Music is the name of the bus I want the index for. Likewise for the Master it would be


If you need to see this visually to make more sense to you, you can check out my short video on youtube here

Thank you! This helped a lot.