0 votes

Script Inherits from native type Animated Sprite, so it can't be instanced in object of type Sprite.

I'm starting to learn Godot and I decided to recreate a game from scratch, I came across this error and can't find a solution.,

in Engine by (12 points)

1 Answer

+1 vote

A script is associated with a specific node. The script must extend that node type. So, at the top of the script, this line must match the node-type the script is attached to:

extends Node2D

If you have a script with that extends Node2D (like above), attached to (for example) a CanvasLayer node, you'll get this error:

Script inherits from native type 'Node2D', so it can't be instanced in object of type: 'CanvasLayer'

So, to fix it, change the extends XXX line in the script to match the node-type the script is attached to.

by (10,890 points)
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 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 webmaster@godotengine.org with your username.