instancing not working with error " _ready: Invalid call. Nonexistent function 'instantiate' in base 'Node2D'.

Godot Version

godot 4.7

Question

Im beginner to gamedev and coding, and I tried following an easy tutorial on instantiating and couldn’t get it to work. Im trying to instance a 2d scene with a meshinstance2d and a rigidbody2d + collisionshape into my main scene.

the main scene only has a camera and the script attached to the main node.

ive attached some photos of my scenes and how they are setup:

thank you for any help you can give :slight_smile:


extends Node2D

@onready var ball = preload(“res://ball.tscn”).instantiate()

func _ready():
var ball_temp = ball.instantiate()
add_child(ball_temp)

You try to instantiate twice. Your ball and ball_temp both instantiate()

Remove it from either of them and then it should work

thank you, youre a real help!