0 votes

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 skillname to be converted to a string for this purpose using load("res://graficos/Skills/" + str(skillname) + ".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:
   damage = 40
   axe_speed = 200
   damage = 30
   axe_speed = 400
 var skill_texture = load("res://graficos/Skills/" + skill_name +  ".png")

 apply_impulse(Vector2(), Vector2(axe_speed, 0).rotated(rotation))

func self_destruct():

func _on_Taxe_body_entered(body):
 get_node("CollisionPolygon2D").set_deferred("disabled", true)
 if body.is_in_group("Enemies"):

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
  can_fire = true
  throwing = false
  speed = 70
in Engine by (17 points)

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.