Trouble with my code getting data from my Json file

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

extends Node2D
var item_name
var item_quantity

func _ready():
var rand_val = randi() % 3
if rand_val == 0:
item_name = “Money”
elif rand_val == 1:
item_name = “Pipe”
else:
item_name = “cup”

$TextureRect.texture = load("res://Item/" + item_name + ".png")
var stack_size = int(Jsondata.item_data[item_name]["StackSize"]) //This part is the error
item_quantity = randi() % stack_size + 1

if stack_size == 1:
	$Label.visible = false
else:
	$Label.text = String(item_quantity)

There’s really not a lot here to go on. What’s the error? It is with Jsondata itself or some other property?

spaceyjase | 2021-11-24 10:14

The actual JSON could also help.

bchmura | 2021-11-30 06:49