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("'hoot"):
		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?

This = const POWERBEAM = preload(“res://Power_Beam.gd”)
or
this = const POWERBEAM = preload(“res://Power_Beam.tscn”)

gd and tscn

ramazan | 2022-02-28 09:50

The problem is likely as answered.

Aside from that, I would advise you update your Godot version later, Godot 3.0 was released 4 years ago, now the engine is version 3.4.3 and had tons of improvements.

Zylann | 2022-02-28 14:05

Well, I would have followed with the current version I have (3.4.2) but the tutorial pretty much called for Godot 3, as there were errors if you used Godot 3.1 so I had to download an older version. (PS nearly done with the tutorial)

newgodot_user | 2022-02-28 14:17

:bust_in_silhouette: Reply From: Box_

umm I think its doing that because u preload a .gd not the .tscn

instead of this

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

use this

const POWERBEAM = preload(“res://Power_Beam.tscn”)

the .gd is a script while the .tscn is the scene