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

Hi,

I am getting this error in the script after hit play.

Error at (2, 12) Class Player hides a global script class.

I typed the script exactly like the instructor. He does a great job. I am using the exact Godot version he is using.

If anyone recognizes the error and can help, I would appreciate it.

Thank you!


at a guess, I would assume the Player class is defined somewhere else.

would you be able to Zip your project folder up and pop it online or DM it over, so i can have a quick look to try and get you back on track.

Darren

Hi,

I sent the file by email. Should I send it in this platform?

If you could pop I on here, would be brill as maybe others have came across the same as well and can have a look.

Darren

The system would not allow me to pop the zipped file here. Is there another option?

My apologies. I am new to this. This is my first time using Godot and posting questions in this community.

I’ve sent you a DM if that’s OK where to upload.

Just to jump in on this as the only time i have seen this error is when the class is being autoloaded.
I would double check that your autoload in the project settings only has two items in it as below.

1 Like

OK. I will check the project settings.

Thank you!

My apologies, I think I posted this question twice. I still need the help though. Perhaps, I can zip and upload this file?

I’ve closed the other question on this as this has more replies.
Did you check the autoload options in the project settings as pictured above to see if Player.gd is in there?

This is what 's in the autoload options.

Hmm thats a little odd as the only thing i can think of other than that is that the player class like Darren suggested is defined somewhere else.

If you can go to where the project is stored and zip the folder up we can take a look as mentioned.
If you can go to the link below and do this and then reply here when its done as the system does not let us know when a file has been uploaded.

Thanks

https://gdev.tv/projectupload

Now this is a strange one.

finally think ive found how to fix it, but not entirely sure what caused it.

firstly, make a backup of your project folder, just in case.

make sure Godot Editor is Closed and not just minimised for the next part.

go into your project folder in windows

then delete the .godot folder shown below.
image

reopen Godot Editor and open your project.
this folder will recompile and that error should be gone.

but I see you are left with two other parse errors.
to get rid of these.
need to ensure that where you have viewport_size on lines 8 and 9.

these have to have a capital V at the start, to match the variable your declaring on line 5

hopefully that sorts the couple of errors out, ill keep digging to see if i can find out what the actual cause was

Darren

1 Like

OK. I will give it a shot tomorrow.

Thank you.

Cool, let us know how it goes please.

The second step worked. Made the V uppercase.

I think I followed the steps correctly. But the results show something is not correct. :smile:

Hi,

I am not sure what we are looking at error wise here as you are in the script view but with no script selected.
If you select a script it should display it fine and you can continue with the course.

If you can update us on what the issue is that i am missing i would be grateful.

Thanks

I am getting this error in the script after hit play.

Error at (2, 12) Class Player hides a global script class.

Is that after deleting the " .godot ’ folder that I mentioned earlier?

If its still there after you done that, any chance you could upload a zipped project folder again so I can have another look please.

Yes.

And, yes. Which shared link should I use?

Privacy & Terms