Invalid access to property or key 'musicvolume' on a base object of type 'Dictionary'

Godot Version

4.4

Question

I’m trying to add saving/loading of settings to my game (based off of a tutorial by DashNothing), but it always throws up the error Invalid access to property or key ‘[thesetting]’ on a base object of type ‘Dictionary’ when i try to load the scene.

I tried this again on other settings besides audio and I noticed the error only affects every value after the first one for some reason? here is the code for both loading it and the settings saving system if helpful:

@onready var musicslider = $musicslider
@onready var soundslider = $soundslider
@onready var voiceslider = $voiceslider
@onready var ambienceslider = $ambienceslider
@onready var outputmenu = $outputmenu
@onready var speakermenu = $speakermenu

func _ready():
	masterslider.grab_focus()
	SettingsConfig.load_audio_settings()
	var audio_settings = SettingsConfig.load_audio_settings()
	masterslider.value = min(audio_settings.mastervolume, 1.0) * 100
	musicslider.value = min(audio_settings.musicvolume, 1.0) * 100
	soundslider.value = min(audio_settings.sfxvolume, 1.0) * 100
	voiceslider.value = min(audio_settings.voicesvolume, 1.0) * 100
	ambienceslider.value = min(audio_settings.ambientvolume, 1.0) * 100
	outputmenu.selected = audio_settings.outputdevice
	speakermenu.selected = audio_settings.speakermode

-- 
```extends Node

var config = ConfigFile.new()
const SETTINGS_FILE_PATH = "user://settings.ini"

func _ready():
	if !FileAccess.file_exists(SETTINGS_FILE_PATH):
		#audio setting
		config.set_value("audio", "mastervolume", 1.0)
		config.set_value("audio", "musicvolume", 1.0)
		config.set_value("audio", "sfxvolume", 1.0)
		config.set_value("audio", "voicesvolume", 1.0)
		config.set_value("audio", "ambiencevolume", 1.0)
		config.set_value("audio", "outputdevice", -1)
		config.set_value("audio", "speakermode", 0)
		#video setting
		config.set_value("video", "resolution", 0)
		config.set_value("video", "windowmode", 1)
		config.set_value("video", "resizewindow", false)
		config.set_value("video", "maxfps", 3)
		config.set_value("video", "vsync", 0)
		config.set_value("video", "darkmode", false)
		config.set_value("video", "brightness", 1.0)
		#keybind setting
		#not yet!
		#other setting
		config.set_value("other", "textspeed", 1)
		config.set_value("other", "language", 0)
		config.set_value("other", "tts", 0)
		config.set_value("other", "autosavefrequency", 0)
		config.set_value("other", "textscale", 100.0)
		config.set_value("other", "guiscale", 100.0)
		config.set_value("other", "autofreezesave", false)
		config.set_value("other", "highcontrast", false)
		
		config.save(SETTINGS_FILE_PATH)
	else:
		config.load(SETTINGS_FILE_PATH)

#save/load audio
func save_audio_setting(key: String, value):
	config.set_value ("audio", key, value)
	config.save(SETTINGS_FILE_PATH)
	
func load_audio_settings():
	var audio_settings = {}
	for key in config.get_section_keys("audio"):
		audio_settings[key] = config.get_value("audio", key)
		return audio_settings

#save/load video
func save_video_setting(key: String, value):
	config.set_value ("video", key, value)
	config.save(SETTINGS_FILE_PATH)
	
func load_video_settings():
	var video_settings = {}
	for key in config.get_section_keys("video"):
		video_settings[key] = config.get_value("video", key)
		return video_settings

#save/load keybind
func save_keybind_setting(key: String, value):
	config.set_value ("keybind", key, value)
	config.save(SETTINGS_FILE_PATH)
	
func load_keybind_settings():
	var keybind_settings = {}
	for key in config.get_section_keys("keybind"):
		keybind_settings[key] = config.get_value("keybind", key)
		return keybind_settings

#save/load other
func save_other_setting(key: String, value):
	config.set_value ("other", key, value)
	config.save(SETTINGS_FILE_PATH)
	
func load_other_settings():
	var other_settings = {}
	for key in config.get_section_keys("other"):
		other_settings[key] = config.get_value("other", key)
		return other_settings

Check out the indentation of your return statement