The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hi, playing around with Godot and being frustrated very fast ;)

Following scene-tree:
Main (Node2D)
- Concept (Sprite) saved as Scene
- labelLMB (Label)

  1. I created a Script under Concept.
  2. Created a Script under Main.
  3. Copied the text from Concept-Script to main-Script
  4. Changed the extends-statement to Node2D
  5. set Node.Script to null at Concept
  6. Deleted the Script completely
  7. Deleted all Scripts
  8. Created new Script under Main
  9. Wrote the Code again

I still get the error: Script inherits from native type 'Reference', so it can't be instanced in object of type: 'Sprite'

WTF!

in Engine by (27 points)

Are you creating the scripts as GDScript or GDNative? You must use the GDScript. If this is not the problem, please share the project

I am using GDScript, so far as I can see. Is there an easy way to attach the project here?

Upload the folder to google docs or something and send the link. Also inform which version of Godot you are using so I can open it with the same one

ok hope it works, used google docs first time ;)
https://drive.google.com/file/d/1bt2_L4J-yR-2Vro0zhZRcrgSTU07WCGS/view?usp=sharing

Godot Version 3.0.6

1 Answer

0 votes
Best answer

Thanks for sharing the project, it was very easy to find the problem looking at it:

You have in your Concept scene a Sprite as root node and it has a script which is blank.

All scripts have to have an inheritance (the extends ... part). It can be another script (put the path of the script, like extend "res://myscript.gd") or an object (extends Node).

If you don't have an inheritance at all or it's wrong (if you had, for example, a script in a Sprite node that extended an Area2D), it will not run and return this error.

It was not very explicit in the error message since it had no inheritance at all (this is why it was saying "inherits from native type 'Reference'". If you had, for example, extends Area2D in that script, the error would be "Script inherits from native type 'Area2D', so it can't be instanced in object of type: 'Sprite'".

To solve that you can or delete the script since it has no code or add extends Sprite if you plan using this script in the future.

by (519 points)
edited by

But:

  1. I chose Node.Script -> null
  2. I deleted the script, for me there isnt a Concept.gd
  3. If I had a script, it should be shown in the top-right corner as a small icon beside the Concept-Node! Nothing shows for me, that there is still a script!

There must be somthing wrong with the ide then.

Here was showing a script icon in the node which leads to a empty and nameless script. After removing it, the problem was solved. You are getting this error because a node has a script and the script extends the wrong object/don’t extends nothing at all.

yes I understood. For me the script-icon isn't shown as I described AND I deleted the file. So there is no other way than making a new Project. Hope such a mistake will not appear later on, when the project becomes bigger.

Actually this is a big argument not to use godot. Nevertheless I will use it, because I like Godot. But when I have such an Error again and no solution, then I will quit Godot - would be pity.

Before deleting it, save as it is and re upload, just to I check it out again

I didnt change anything, I have a buckup of that project.

I used the Concept.tscn in the new Project, and had the same issue.

Deleting the project its never a solution. If there is a problem, search in the right place and you will find the cause of it.

Imagine if the project gets bigger and you run through a problem? Would you hope to it fix itself? It's important to learn how to debug and understand the error messages.

If the error is the same, that is the problem, you have a script without the extends ... part or it is wrong as I said before. Take a look at all your nodes with script and see if they match.

Of course, bugs with the engine can happen. If this is the case (what I doubt) you should create an issue on the GitHub page.

Wait 5 minutes from the time i'm posting this comment and see this video (you can't open before because I'm uploading it rigth now) : https://youtu.be/myJWiGvZnc0

English is not my main language, so maybe I was not understandable. I think this is bad behaviour of Godot. I started the old Project again, and this time the field node-script was not null. I set it null several times, no script icon, the linked script-file doesnt exist.

Then try creating an empty script for it just with one line: extends Sprite and try again

Thanks for your Video that showed me where you looked for the Script-Icon. That is what confused me before, because the Script-Icon was also shown next to the Scene-Icon before.

Ohhh now I got what you was doing, you were removing the script for the instance of that scene but it would still crash since when Godot tries to build the original scene, it crashed.

Yeah, debugging instanciated scenes you always want to look the original one.

Glad you got this fixed and learned a litte more about Godot xD
If you don't have further questions related to this problem, please set the best answer to "close" this questions on the community.

thanks for your help ^^

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.