Invalid Call. Nonexistent function 'instance' in base 'GDScript'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By newgodot_user
extends KinematicBody2D


const SPEED = 52.5
const GRAVITY = 10
const JUMP_POWER = -200
const FLOOR = Vector2(0, -1)

const POWERBEAM = preload("res://Power_Beam.gd")

var velocity = Vector2()

var on_ground = false

func _physics_process(delta):
	
	if Input.is_action_pressed("right"):
		velocity.x = SPEED
		$AnimatedSprite.play("run")
		$AnimatedSprite.flip_h = false
	elif Input.is_action_pressed("left"):
		velocity.x = -SPEED
		$AnimatedSprite.flip_h = true
		
		$AnimatedSprite.play("run")
	else:
		velocity.x = 0
		$AnimatedSprite.play("idle")
		
	if Input.is_action_just_pressed("jump"):
		if on_ground == true:
			velocity.y = JUMP_POWER
			on_ground = false
			
	if Input.is_action_just_pressed("shoot"):
		var powerbeam = POWERBEAM.instance()
		get_parent().add_child(powerbeam)
		
	velocity.y += GRAVITY
	
	if is_on_floor():
		on_ground = true
	else:
		on_ground = false
		if velocity.y < 0:
			$AnimatedSprite.play("jump")
		else:
			$AnimatedSprite.play("fall")

	velocity = move_and_slide(velocity, FLOOR)

I’ve been following UmaiPixel tutorials (on part 5) and for some reason, it gives me this error. My Godot version is 3.0, but his Godot version is 3.0.6. Is that why?

PS On line 36: var powerbeam = POWERBEAM.instance()

newgodot_user | 2022-02-27 23:04

:bust_in_silhouette: Reply From: newgodot_user

Just needed to change the constant preload from gd to tscn since gd means godot script

1 Like