Invaild operands 'Object' and 'String' in operator '=='

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dead_lucky_32
func create new enemy (type),
Var enemy = Battle Units. Enemy
var oppcheck = randongen.chance(0)

create new opp() 

Elif enemy == null
If type == 'null'
var Enemy = Enemies. Front() 
var CreateEnemy = Enemy. instance()
EP.add child CreateEnemy)

if = "Chest";
CreateEnemy. fake = true
battleButtonContainer.hide ()
O battleOppContainer.get_node("OpenActionButton).show()
print("Mimic Created")

CreateEnemy.connect("on_death", self, _on_Enemy_Death)

var CreateEnemy = type, instance()
EP.add child(createEnemy)

I can’t see to find the error or at least how to fix it, btw I used Google lens to get the text because I’m using my phone so sorry if it’s a little hard to read I fixed it up a bit to be more readable

:bust_in_silhouette: Reply From: Zylann

If type == 'null'

'null' is a string. type is probably an Object in this case. That’s indeed the wrong comparison. Use null instead, or if you really expected a string containing “null”, you may look for the code sending you type.

Yeah that was the problem, thank you for that!

Dead_lucky_32 | 2020-01-12 22:24