Getting an error trying to instance a scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By imekon
:warning: Old Version Published before Godot 3 was released.

I’m getting an error:

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

The line in queston is:

func createSubRock(res, pos, x, y):
var _rock = load(res)
var rock = _rock.instance()     -------- HERE!!!
rock.set_pos(Vector2(pos.x + x, pos.y + y))
rock.score = 75
rock.add_to_group("rocks")
main.add_child(rock)

On one machine, it works but on another, it stops. What am I doing wrong here?

Can you provide more information? Like:
Which Godot version are you using?
What are you trying to do?
Does the debugger/console say other things?
Im asking you because there can be more erros. Maybe Godot doesn’t have admin permissions to write a file, or some methods changed in newer Godot versions

GunPoint | 2017-11-11 20:59

:bust_in_silhouette: Reply From: imekon

Oh dear, I’ve got my script attached to a CollisionPolygon2D node as well as RigidBody2d!