Code Error Help!

Godot Version

Godot Version 4.2.2 Stable


the error is - Invalid get index of type ‘String’ (on base: ‘Dictionary’). -
Hi I’m making a Character Creator Scene where players can choose what their player is wearing but apparently I’m struggling to understand which part is going haywire like when I use the global code for the Creator Scene It’s working I can pick which clothes I can wear but when I use it for the Player Scene it’s broken, just an error. Can someone tell me what’s wrong and how to fix it? much appreciated.

so basically my code in the player script uses the global script to get the different texture.

My code in the Player Script (the above script is just movement and the ready function where the script below gets called)

My code in the Global Script( this is where the texture is preloaded )

and this is where the code gets pulled

so like when I get the selected values it should get its texture from the preloaded one. It works fine for the creator scene but it malfunctions in the player script.

Maybe its not supposed to be empty?

not really… I was just following a tutorial and apparently it’s coded like that but if you think it’s not suppose to be empty. then what do I put there? I’m kinda lost haha

The Global.selected_body is empty. So on the line where the error occurs it tells you there is no Key that matches "".

If you’re using a tutorial, maybe continue the tutorial and the person will eventually get to this? Other than that, Global.selected_body has to be one of the already existing keys in the dictionary body_collectionM. Eg. "0", "1", "2", "3", "4", or "5".

1 Like

the tutorial already finished and they left it empty on purpose though

this is the final code that was posted on their github

Anyways with a little bit of tinkering I finally got the code to work if I just don’t run the player scene. I specifically HAVE to run it on the main scene kinda weird but it do be like that haha I’ll just check this as solve so it won’t bother anyone anymore… Thanks for the help, I’m kinda new to the whole thing so the little things matter to me… very much appreciated thanks