Help with an error

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

(Sorry for my english i’m using google translator)
I got this error “Invalid type in built-in function ‘set_value’ in base” ProgresBar “. Cannot convert argument 1 from float to String.”

extends CanvasLayer

onready var hp = experion.hp

func _input(event):
    if event.is_action_pressed('ui_focus_next'):
    hp -= 10
    pass

func _physics_process(delta):
    get_node("Control/Healbar").set_value(hp)
    if hp >= 1:
         hp += delta * 0.6

I feel there may be something wrong with your error message. Right Click and Copy it.

Dlean Jeans | 2019-07-15 08:52

:bust_in_silhouette: Reply From: Ertain

The variable in the function set_value() seems to think the argument that you are using is a string type. Try casting the value to a float type, i.e. set_value( float(hp) ).

error: invalid operands ‘String’ and ‘int’ in operator ‘>=’

Comet | 2019-07-15 13:13