Godot Version
V4.2.1
Question
hi i am trying to make a if contains statement and i don’t know how to do it. can anyone help?
V4.2.1
hi i am trying to make a if contains statement and i don’t know how to do it. can anyone help?
If I understand you correctly, depending on your case there’s two possible options:
Combining a for loop with an if condition:
for X in Y:
if X #insert your conditions here:
#do stuff here.
or you coud use a match statement:
match <expression>:
<pattern(s)>:
<block>
<pattern(s)> when <guard expression>:
<block>
<...>
See GDScript reference — Godot Engine (stable) documentation in English
Do you mean something like “does Array contain X”? Then the solution is just:
if value in array: