Giving a random player a role (Among Us)

I'd like to recreate Among Us, but I don't know how I can randomly pick a player and give him a role (imposter, crewmate).

Comments

  • Using Player properties or Room properties, booth should work.

    I wrote some code that should be useable out of the box using player properties https://pastebin.com/sf3TJjrP
    Usage should be somewhat clear.
    Call
    AssignTagToRandomPlayer(string tag)
    
    to assign a given tag/roll whatever you wanna call it to a random player.
    Get the player that has a given tag.
    GetPlayerWithTag(string tag)
    
    or get all players with a tag
    GetPlayersWithTag(string tag)
    
  • @decoyishere You can also access other players 'Player' object through PhotonNetwork.PlayerListOthers. For example you could do any of the following:
    var selectedPlayer = PhotonNetwork.PlayerListOthers[Random.Range(0, PhotonNetwork.PlayerListOthers.Length - 1)]
    
  • S_Oliver wrote: »
    Using Player properties or Room properties, booth should work.

    I wrote some code that should be useable out of the box using player properties https://pastebin.com/sf3TJjrP
    Usage should be somewhat clear.
    Call
    AssignTagToRandomPlayer(string tag)
    
    to assign a given tag/roll whatever you wanna call it to a random player.
    Get the player that has a given tag.
    GetPlayerWithTag(string tag)
    
    or get all players with a tag
    GetPlayersWithTag(string tag)
    

    i am getting in your pastebin code.
    Errors :
    The name 'SetTag' does not exist in the current context
    The name 'GetTag' does not exist in the current context
  • psychosija wrote: »
    S_Oliver wrote: »
    Using Player properties or Room properties, booth should work.

    I wrote some code that should be useable out of the box using player properties https://pastebin.com/sf3TJjrP
    Usage should be somewhat clear.
    Call
    AssignTagToRandomPlayer(string tag)
    
    to assign a given tag/roll whatever you wanna call it to a random player.
    Get the player that has a given tag.
    GetPlayerWithTag(string tag)
    
    or get all players with a tag
    GetPlayersWithTag(string tag)
    

    i am getting in your pastebin code.
    Errors :
    The name 'SetTag' does not exist in the current context
    The name 'GetTag' does not exist in the current context

    nvm. i am dumb. :blush:
  • now i am getting this error : The name 'PunPlayerTag' does not exist in the current context