Cant get a switch skill bar to work on match | Invalid operands String and Nil in operator +

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

I was following a video tutorial that shows how to make an switch skill bar in godot but every time i run the game i just get this error " Invalid operands String and Nil in operator +"
i tried to command the skill_name to be converted to a string for this purpose using load(“res://graficos/Skills/” + str(skill_name) + “.png” but i m getting this other error, “Invalid type in Vector 2 constructor. Cannot convert argument 1 from nil to float”

Sorry if i cant explain better im still a beginner

extends RigidBody2D


var axe_speed 
var life_time = 3
var damage 
var skill_name 


#var fire_direction
#func _init(_skill_name):
# skill_name = _skill_name


func _ready():
 match skill_name:
  "Spear":
   damage = 40
   axe_speed = 200
  "Axe":
   damage = 30
   axe_speed = 400
 var skill_texture = load("res://graficos/Skills/" + skill_name +  ".png")
 get_node("Projectile").set_texture(skill_texture)
 
 apply_impulse(Vector2(), Vector2(axe_speed, 0).rotated(rotation))
 self_destruct()
 
func self_destruct():
 yield(get_tree().create_timer(life_time),"timeout")
 queue_free()
 
func _on_Taxe_body_entered(body):
 get_node("CollisionPolygon2D").set_deferred("disabled", true)
 if body.is_in_group("Enemies"):
  body.on_hit(damage)
 self.hide() 


and in the player script  i have this 


func skill_loop():
 if Input.is_action_pressed("shoot")and can_fire == true:
  can_fire = false
  throwing = true
  speed = 0
  get_node("PlayerAxis").rotation = get_angle_to(get_global_mouse_position())
  var axe_instance = axe.instance()
  axe_instance.position = get_node("PlayerAxis/axePosition").get_global_position()
  axe_instance.rotation = get_angle_to(get_global_mouse_position())
  axe_instance.skill_name = selected_skill
  get_parent().add_child(axe_instance)
  yield(get_tree().create_timer(rate_of_fire),"timeout")
  can_fire = true
  throwing = false
  speed = 70

The error does seem like your skillname is nil and i see you are setting it in the player script to whatever selected_skill is, i would double check selected skill before it is set into the skill name with either a debugger or by printing it’s value to the console.

tastyshrimp | 2019-12-15 00:36