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 (521 points)
edited by

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.