Invalid set index 'nice_name' (on base: 'Nil') with value of type 'String'' when it tries to read from a json file

Godot Version



I was trying to use a plugin called “SImple Card UI” for my game and I was supposed to make a JSON file with the card details (nice_name refers to the name of the card). But after doing everything as it was in the example, it was showing this error.

func _create_card_ui(json_data : Dictionary):
	var card_ui = extended_card_ui.instantiate()
	card_ui.frontface_texture = json_data.texture_path
	card_ui.backface_texture = json_data.backface_texture_path
	card_ui.return_speed = card_return_speed
	card_ui.hover_distance = card_ui_hover_distance
	card_ui.drag_when_clicked = drag_when_clicked

	card_ui.card_data = ResourceLoader.load(json_data.resource_script_path).new()
	for key in json_data.keys():
		if key != "texture_path" and key != "backface_texture_path" and key != "resource_script_path":
			card_ui.card_data[key] = json_data[key]
	card_ui.connect("card_hovered", func(c_ui): emit_signal("card_hovered", c_ui))
	card_ui.connect("card_unhovered", func(c_ui): emit_signal("card_unhovered", c_ui))
	card_ui.connect("card_clicked", func(c_ui): emit_signal("card_clicked", c_ui))
	card_ui.connect("card_dropped", func(c_ui): emit_signal("card_dropped", c_ui))
	return card_ui

The error shows at the part where the json_data.key is being assigned to card_data[key]

I thought it must be the json file I used, but i used the example’s and it showed the same error. The error isn’t specific to nice_name, it shows the same for the other keys too.

Can you open the JSON file and see what’s inside?