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: How do I make a script that choses 3 players out of all of them?

Previous Thread :: Next Thread 
ruebot is not online. ruebot
Joined: 08 Feb 2008
Total Posts: 203
22 Jul 2011 08:51 AM
This is a part of my script (That has an error)

local m = math.random(join, 3) -- I though that this would choose 3 players out of all players.

m.join.TeamColor = "Dark green"

-- How do I make it choose 3?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
22 Jul 2011 08:54 AM
local plyrs = game.Players:GetChildren()
for i = 1, 3 do
local X = math.random(1, #plyrs)
plyrs[X].TeamColor = BrickColor.new("Dark green")
table.remove(plyrs, X)
end


      ~~~ AFF ~~~
Report Abuse
Alex645ca is not online. Alex645ca
Joined: 02 Feb 2009
Total Posts: 2531
22 Jul 2011 09:00 AM
@Agent

I was just reading the object browser because I found a bunch of random new object classes in the insert>object menu, and the getchildren tables are read-only.

local plyrs = game.Players:GetChildren()
for i = 1, 3 do
local X = math.random(1, #plyrs)
if plyrs[X].TeamColor ~= BrickColor.new("Dark green") then
plyrs[X].TeamColor = BrickColor.new("Dark green")
else
i = i - 1
end
end

I suppose that would work better, idk.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
22 Jul 2011 09:09 AM
Nothing out of the league here, but won't both of your scripts allow the script to chose the player over? Like it choses the same player?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
22 Jul 2011 01:55 PM
"and the getchildren tables are read-only."


That statement is a lie.


t = workspace:GetChildren() print(#t) table.remove(t, 1) print(#t)
> 7
> 6


      ~~~ AFF ~~~
Report Abuse
TigerBloodd is not online. TigerBloodd
Joined: 24 Oct 2010
Total Posts: 2430
22 Jul 2011 02:15 PM
local player game.Players:GetPlayers()
print(player[math.random(3,#player)])

Much easier
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