Invalid Get index on base: Node2D

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

Hi, I want to run a script of a game that I am creating but it gives me the error “Invalid get index” velocidad_min "on base Node2D
Attached script

extends Node2D

export (PackedScene) var Roca
var Score

func _ready():
	randomize()
func nuevo_juego():
	Score = 0
	$Player.inicio($Positiondeinicio.position) #posicion de inicio del player
	$Iniciotimer.start()
	
	
func _on_Player_golpe():
	$Scoretimer.stop()
	$Rocatimer.stop() 


func _on_Iniciotimer_timeout():
	$Rocatimer.start()
	$Scoretimer.start() # Replace with function body.


func _on_Scoretimer_timeout():
	Score += 1 # Replace with function body.
	



func _on_Rocatimer_timeout():
	$camino/rocaposicion.set_offset(randi())
	
	var R = Roca.instance()
	add_child(R) 
	
	var d = $camino/rocaposicion.rotation
	
	R.position = $camino/rocaposicion.position
	
	d += rand_range(-PI /4, PI /4)
	R.rotation = d
	R.set_linear_velocity(Vector2(rand_range(R.velocidad_min, R.velocidad_max), 0).rotated(d))

I indented your code. You can do it by selecting the whole code, and click the “Code Sample” button { }.

Zylann | 2020-03-09 18:51

:bust_in_silhouette: Reply From: Zylann

You are getting this error because the object inside R does not have a velocidad_min property.
R is an instance of the scene stored in Roca. Look in the inspector for the scene you assigned, and check if it has a root script with that property in it. Maybe you made typo?