Choosing a random object with a certain tag

Okay so here is the problem, I’m quite new with Unity and I need help.

I have 6 objects in my scene called ‘Slab’ and every slab has a tag ‘Slabs’.
What I need the script to do is to choose ONE of them and then destroy it.

GameObject[] Slabstlist;
Slabslist() = GameObject.FindGameObjectsWithTag("Slabs");

That is how I think I should do it but I get an error, (error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer)

After that I’m not sure how I should continue, I’ve been looking for similar questions and only found one but there was no answer so if anyone is able to help me thank you :slight_smile:

Take out the () next to Slabslist, and spell it correctly (you have two different spellings there).

A random one would be Slabslist[Random.Range(0,Slabslist.Length)]

In JS i think that should work:

var Arry : GameObject[];
var randomNumber : float;

function Start()
     Arry = GameObject.FindGameObjectsWithTag("Slabs");
     randomNumber = Random.Range(0,Arry.Length+1);

however i am not sure, I didnt tested that out :slight_smile: