• Need help with tables!
    4 replies, posted
Hello, So i'm trying to get the name of a random player in a team (See below) This code works however instead of just getting the players name I also get "Player [1][PLAYERNAME]" I'm wondering how I can just the playername and not the other stuff. Any help would be appreciated! [CODE] RoundWarden = tostring(table.Random( (team.GetPlayers( 2 ) ))) [/CODE]
[URL="https://wiki.garrysmod.com/page/Player/GetName"]GetName()[/URL]
[QUOTE=boxvader;49371710][URL="https://wiki.garrysmod.com/page/Player/GetName"]GetName()[/URL][/QUOTE] How would I use this in the code? table.Random( team.GetPlayers( 2 ):GetName() )?
Get rid of the tostring() it's not needed. The variable is being declared as an entity thats why it looks so weird. So all you need to do is [CODE]RoundWarden = (table.Random( (team.GetPlayers( 2 ) )):GetName()[/CODE] [editline]value[/editline] Or you can do what niandra said
RoundWarden:Nick() - you may wanna read up on how variables work before doing more complex stuff
Sorry, you need to Log In to post a reply to this thread.