I am having a problem with save/load function in my project
Basically, I want to save an array of item Id's in player inventory, but I get error mentioned in the title.

Here is the code:

var InventoryData = "res://Assets/Data/Inventory.json"
var InventoryID = []
var Invi = 1

func inventory_save():
var file = File.new()
file.open(InventoryData, File.WRITE)
file.store_var(InventoryID.append(Invi))
file.close()

I change Invi in another script, but the error stays the same

  • append() is valid for an Array. In your code, it looks like InventoryID is an Array, so that should be fine. And I just tried your code, and it works fine. Most likely the variable InventoryID is being overwritten somewhere with a string value.

append() is valid for an Array. In your code, it looks like InventoryID is an Array, so that should be fine. And I just tried your code, and it works fine. Most likely the variable InventoryID is being overwritten somewhere with a string value.