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: Question

Previous Thread :: Next Thread 
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
10 Jan 2013 02:18 PM
So i got this script of a naked guy with blue colors, anyway he posted this script:


function randomplr()
local players = game.Players:GetPlayers()
return players[math.random(1, #players)]
end

print(randomplr())




So, the return, did it return ALL the players, and another question, the # sign before players, does that make it so it will print a number?
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Jan 2013 02:21 PM
What that does is return a random player.

I'll describe it:
define function randomplr
set local variable players to a table of all players in game
return math.random of 1 to the number of items in the table (number of players)
end function

print what the function randomplr returns
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
10 Jan 2013 02:24 PM
Oh i get it, but another question:

for _,v in pairs(game.Players:GetPlayers()) do
end

print(#v) will that print a number of the players in game?
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
10 Jan 2013 02:31 PM
#game.Players:GetChildren()

That will.
Report Abuse
RoboTestGear is not online. RoboTestGear
Joined: 28 Dec 2009
Total Posts: 3063
10 Jan 2013 02:40 PM
function Players()
return game.Players.NumPlayers
end

function RandomPlayer()
if Players() >= 1 then
return game.Players:GetChildren()[math.random(1,Players())]
end
end

Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
10 Jan 2013 03:04 PM
You can also use the NumPlayers property like ^ did
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
10 Jan 2013 03:10 PM
I laik doing it universal way. I still don't understand why roblox should waste their time on little properties like NumPlayers, instead of fixing that GetMouse.MouseIcon problem.
Report Abuse
RoboTestGear is not online. RoboTestGear
Joined: 28 Dec 2009
Total Posts: 3063
10 Jan 2013 11:02 PM
#game.Players:GetChildren() would return the number of objects in players.
game.Players.NumPlayers returns the exact number of players in the game :D
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
11 Jan 2013 01:14 AM
Well you can't have player anywhere else, anyway.
Report Abuse
1WOOF1 is not online. 1WOOF1
Joined: 03 May 2009
Total Posts: 20682
11 Jan 2013 04:26 AM
[ Content Deleted ]
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
11 Jan 2013 05:01 AM
Which idiot would do that.... We have already enough unused place in Lighting.
Report Abuse
1WOOF1 is not online. 1WOOF1
Joined: 03 May 2009
Total Posts: 20682
11 Jan 2013 05:02 AM
[ Content Deleted ]
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
11 Jan 2013 05:11 AM
Well yeah, as I said, idiots does.
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