an embedded statement may not be a declaration or labeled statement

So i was running through some code in my unit selection script and i ran into the problem stated above.

GameObject SelectedObj = hit.collider.transform.FindChild("Select").gameObject;

This particualr line gave me some errors however i haven’t been able to solve them yet.

Any help would be appriciated.

The problem is most likely caused by surrounding code. It means that your SelectedObj might have been assigned before in the header of a loop for example. Could it be that your line is part of a for/each loop? Could you post the rest of your code?

Funny that the API documentation does not even list a method FindChild for Transform… but you don’t get an error message on compilation, so it must exist.