I had a problem with the class "InventoryItem" when I want to load inventory of my game in Godot 4.2

Godot Version

Godot Engine 4.2


Hi, I want to know why my code fails when I create the class InventoryItem and I try to load the inventory? I get the following error with my code: Parser Error: Class “InventoryItem” hides a global script class. Just in case, the InventoryItem class inherits from Resource class, how can I solve this error in my code? Thank you for read this topic!

This can happen if you have made something and Autoload an then have also given it a class_name in the script itself. Autoload names are defined in the interface, not the script.

Otherwise, you’re duplicating a class name that’s already part of gdscript.

I got a error very similar to the previous one, Parser Error: Class “InventoryItem” hides an autoload singleton. What should I do to solve this error?

I believe it means you have two classes with the same name, which can occur when you duplicate a built in class name (not sure if that is a built in class name) or when you give an Autoload a name and then set class_name on that file.

Try changing the name of your class to something else or if it’s an Autoload, remove the class_name declaration.