generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: this would work, right

Previous Thread :: Next Thread 
TwoRainbowApples is not online. TwoRainbowApples
Joined: 16 Feb 2011
Total Posts: 13346
03 Jan 2014 10:39 PM
PlayerTable = {}
local players = Game:GetPlayers()
for i=1,#players do
table.insert(PlayerTable, players[i].Name)
randplayer = PlayerTable[math.random(1,#PlayerTable)]
table.remove(PlayerTable, randplayer.Name)
randplayer2 = players[math.random(1,#players)]
table.remove(PlayerTable, randplayer2.Name)
--code
end

Twitter - @askshanerbx, Don't trust koolaidekiller.
Report Abuse
tuxedoman23 is not online. tuxedoman23
Joined: 24 Apr 2009
Total Posts: 4670
03 Jan 2014 10:43 PM
If you're trying to get a random player, you don't have to establish a new table. Just try this:

local players = game.Players:GetPlayers()

local randomPlayer = players[math.random(1, #players)]

print(randomPlayer.Name.." was chosen.")
Report Abuse
travddm is not online. travddm
Joined: 29 Mar 2012
Total Posts: 926
03 Jan 2014 10:44 PM
No.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
03 Jan 2014 10:47 PM
^look at wat hes trying to do first...

btw it wont work. here try this.

PlayerTable = Game.Players:GetPlayers()
local index1 = math.random(1,#PlayerTable)
randPlayer1 = PlayerTable[index1]
table.remove(PlayerTable, index1)
local index2 = math.random(1,#PlayerTable)
randPlayer2 = PlayerTable[index2]
table.remove(PlayerTable, index2)
Report Abuse
travddm is not online. travddm
Joined: 29 Mar 2012
Total Posts: 926
03 Jan 2014 10:53 PM
@above I did look at what he's trying to do. His answer is no.
Report Abuse
TwoRainbowApples is not online. TwoRainbowApples
Joined: 16 Feb 2011
Total Posts: 13346
03 Jan 2014 10:53 PM
tux, I'm making it so it doesn't choose the same player.
and thanks, wazap.

Twitter - @askshanerbx, Don't trust koolaidekiller.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
03 Jan 2014 10:56 PM
@trav I was referring to the person above you. You ninjaed while I was typing :c
Report Abuse
TwoRainbowApples is not online. TwoRainbowApples
Joined: 16 Feb 2011
Total Posts: 13346
03 Jan 2014 10:57 PM
wazap so
local players = Game:GetPlayers()
for i=1,#players do
local index1 = math.random(1,#players)
randplayer1 = PlayerTable[index1]
--do something with randplayer
table.remove(PlayerTable, index1)
--so he can't be picked again
end

Twitter - @askshanerbx, Don't trust koolaidekiller.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
03 Jan 2014 11:00 PM
Why are you so insistent on Game:GetPlayers() -.-

its Game.Players:GetPlayers()


local players = Game.Players:GetPlayers()
for i=1,#players do
local index1 = math.random(1,#players)
randplayer1 = players[index1]
--do something with randplayer
table.remove(players, index1)
--so he can't be picked again
end
Report Abuse
TwoRainbowApples is not online. TwoRainbowApples
Joined: 16 Feb 2011
Total Posts: 13346
03 Jan 2014 11:01 PM
I meant game.Players:GetPlayers() lol
i keep typo'ing
xd

Twitter - @askshanerbx, Don't trust koolaidekiller.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image