what does Invalid get index 'Ammo' (on base 'Dictionary' mean

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dallasboi

im trying to make a first person shooter but im trying to get my ammo to show up with this

weapon_ui.text = weapon_data[“Name”] + ": " + weapon_data[“Ammo”] + “/” + “ExtraAmmo”

but apparently it wont work here is the rest of the code btw this is from another script

var weapon_data = {
“Name” : weapon_name,
“Image” : weapon_image,
“ExtraAmmo” : str(extra_ammo),
“Ammo” : str(ammo_in_mag)

When you are typing in keywords/variables with underscores, surround it with the backwards apostrophe character. For example: weapon_ui.text = weapon_data["Name"] + ": " + weapon_data["Ammo"] + "/" + "ExtraAmmo"

Snail0259 | 2021-07-15 11:51

:bust_in_silhouette: Reply From: sash-rc

This weapon_data["Ammo"] (extra underscore) conflicts with var weapondata.

thanks friend

dallasboi | 2021-07-15 15:08

no wait the underscore isnt showing

dallasboi | 2021-07-15 16:37

im following a tutorial by skyvastern its called Godot FPS Tutorial - Part 3 - Firing, Reloading and Ammo Management and on 21:44 is what im stuck on

dallasboi | 2021-07-15 17:01

Maybe try downloading his project files here:
GitHub - Skyvastern/fps-tutorial: Project files for the FPS tutorial series.

Open up his part 3 project and then scroll down the script side-by-side with your project to see what differences there are. If you can’t find anything, try pasting his entire code into yours and see if it actually works with your version.

Yuminous | 2021-07-16 01:32