Check for tags

In the documentation, I found that to check for the specific tag on Entity, I have to write the following order

entity.tags.has(“tagName”), but in my case, I have the error " Cannot read properties of undefined (reading ‘tags’)", in the console I can see my entity is not null and the tag is inside tags property, am I doing this right or?


Hi @Dava,

That code should work for an entity. What are the contents of the this.elements array?

If it’s a list of element components, you need to do this to access the entity of the element:

const entity = this.elements[i].entity;

if(entity.tags.has('Image') === true){
}
2 Likes

this.elements is array of Entities
I will try debugging, something is probably messing with array
Thank you @Leonidas :slight_smile:

1 Like