Godot 4: Error at (2, 12) Class Player hides a global script class

that one please. and ill get a look, see if ive missed anything, cheers

Done.

Thank you!

1 Like

k, ive had a look.

well i dont know whats happening at all, this is strange.

after the initial play, its creating a duplicate of the scripts folder, but with a capital S.
so this would be the cause of a duplicate player script and so the duplicate class_name declaration.

but,

its only in the editor, there isnt a sign of a duplicate folder in the file system at all tho.

what i might suggest is to get Godot 4.1.3 the same as Kaan as when i open the project up in there, there isnt any issues and plays fine.
but before opening straight away in 4.1.3, delete the .godot folder first as all the import and other caching/meta data is stored in there.
if you delete that .godot folder then open in 4.1.3 it should be ok from what i can see.

got to be a bug with 4.2.

ive seen it reported on github so ive added to that case notes as well.

Strange one @Marc_Carlyon , just for a heads up in case you spot it elsewhere on your travels.

2 Likes

Had the same problem earlier today and figured out the solution. In my case I renamed the folder that my script was saved in from “Scripts” to “scripts”. This is where I ran into this issue. It seems Godot is not correctly changing the resource path for the script in question as it was still pointing to the “Scripts” instead of “scripts”. To solve this, detach the script, and close the scene it was attached to. Then open the script in question in script editor, right click on the filename and select “Save As”. Then point it to the correct folder (“scripts” in my case) and allow it to override. Double check in the script editor that it’s now pointing to the correct folder and your problem should be solved.

1 Like

Cool that you got a workaround. ill have a look at his project and try that.

yep that seems to work.

cheers for the share, awesome stuff figuring that one out :muscle:

1 Like

Glad it worked. It seems that changing folder names midway in a project messes things up badly. As long as there’s a single reference to the script, like a player scene placed in a world scene for example, Godot will constantly create duplicate folders and files in the editor and break stuff again. So one has to either start with a clean project and name and import everything correctly from scratch or one has to go through every instance and find that reference. I chose the first option because I still have no idea where the old reference to my script was hanging around.

1 Like

Okay, after some more tinkering the easiest solution is to close all scenes and scripts and then to rename the folder back to what it was and to then rename it again to what you want it to be. Then close Godot and open the file, global_script_class_cache.cfg in the .godot folder of your project and double check that the folder path(s) match the folder name you changed to (case sensitive). Or just delete the file entirely. Now you can open the project again and it should stop reverting back to old or incorrect folder names.

This should probably be reported as a bug as it seems that renaming folders might mess things up if you have a script open in editor that is inside the folder being renamed.

I will give it a shot shortly

Actually, I don’t know what steps I need to take.

This was my assumption as well much like in unity sometimes if you rename things in previous issues the metadata gets confused and recreates the folder within unity and not the file system.
I presume this is a similar bug.

Following the instructions given in Akanaro’s post

  1. Rename your scripts folder back to “Scripts” noting the capital S in windows
  2. Go to the .godot folder inside your project in windows
  3. Delete the global_script_class_cache.cfg file
  4. Start godot and open the project.

This should completely solve the issue

OK, I will try it now.

Thank you!

Should I delete the file with the “scripts”? There seems to be 2 folders named scripts now.

Screenshot 2024-02-04 173600

It shouldnt need deleting if you renamed it in the file system back to Scripts and then deleted the .godot folder with the project closed.
@OboShape Any ideas?

I’m just on way to work.

But what I did was, removed all the scripts from every node.
Opened each script and use ‘save as…’ to ensure the script is saved in correct place.
Then reopen project and add the scripts back in.

If you would be OK, what I’ll do is redownload and repair the project, then put it online for you to download.

Will be tonight or later today when I can get time to do it.

If that’s OK.

1 Like

hopefully Toure,

this is now the errors fixed, ive uploaded a folder that contains the entire project folder.
should be good to go with that.

give it a go please and see if the errors have cleared.

https://drive.google.com/drive/folders/1GeGVeV_amnpTJn9dx0DG9Uh1glaGvtM2?usp=sharing

Thank you!

I will give it a shot!

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms