Script Error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By slightly_seasoned

So I made a script for my player node [ aNode2D which has a KinematicBody2D as it’s child] & decided to redo it because it was too messy, & also because most of it wasn’t original [which brings my motivational levels down to the depths of hell.] So I deleted it in the file system, closed it, & started a new one. I finished the new player script, attached it to the player & this error popped up in the “Output” tab: modules/gdscript/gdscript.cpp:813 - Condition "err" is true. Returned: err Cannot load source code from file 'res://player_script.gd'. Failed loading resource: res://player_script.gd. Make sure resources have been imported by opening the project in the editor at least once.

What’s going on, & how do I fix it?

Is the phantom player_script.gd still attached to a node in your project?

timothybrentwood | 2021-05-08 22:49

It’s attached to the Node2D

slightly_seasoned | 2021-05-08 22:50

:bust_in_silhouette: Reply From: timothybrentwood

The editor keeps meta-data about all of the different connections you make between resources (that’s how it builds your project when you go to run it) . During the startup process, it sees that you still have the player_script.gd attached to a Node2D but it fails to load the player_script.gd file from the operating system so it yells at you about it. Two solutions here:

  1. Remove the player_script.gd from the Node2D in the editor by right clicking the Node2D and selecting Detach Script.
  2. Replace the player_script.gd by creating a new player_script.gd in the res:// folder.

When I took it out of the folder it was in, it seemed to work. But when I put it back in it doesn’t. How do I fix this?

slightly_seasoned | 2021-05-09 01:19

That’s very strange. Try this:

  1. Move your player_script.gd completely out of your project folder -
    like to your desktop.
  2. Right click -> Detach Script on the Node2D that’s giving you
    issues.
  3. Attach a brand new script to that same node.
  4. Copy the contents of your original player_script.gd (from step 1)
    into the new script that you just created.

timothybrentwood | 2021-05-09 02:07

:bust_in_silhouette: Reply From: Animaliss

Faced a similar problem.
Installed Asset… got a bunch of errors and removed it back.
The result is a ‘File not found’ error every time the project is run.
(Even though it was not connected anywhere)

Solution:
Throw the project folder into VSC and enter in the search the file that is not found.
In my case, I found a line (in [autoload]) containing:

 BetterTerrain="*res://addons/better-terrain/BetterTerrain.gd"

After removing it, the problem, of course, disappeared.
For some reason, Godot does not have adequate options for working with Assets/Plugins, such as choosing the download path (everything flies to res://) or even just deleting downloaded Assets…