Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

foreach error, please help

Discussion in 'Scripting' started by AiDev123, Apr 7, 2020.

  1. AiDev123

    AiDev123

    Joined:
    Sep 7, 2016
    Posts:
    16
    I copied code from this video
    to finish my multiplayer game. The finished code is 13:22 in the video, and it's giving me an error in the unity editor saying "foreach statement cannot operate on variables of type `UnityEngine.GameObject' because it does not contain a definition for `GetEnumerator' or is inaccessible". Not really sure how to fix this
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,741
    You've got an error in your code, please post your own code rather than posting a video containing the code your code should look like.

    I'm guessing your line 13 doesn't match the video's line 13.
     
  3. AiDev123

    AiDev123

    Joined:
    Sep 7, 2016
    Posts:
    16
    fixed, just forget to add a couple of brackets