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: Picking random player's name.

Previous Thread :: Next Thread 
LightedRoblox is not online. LightedRoblox
Joined: 16 Apr 2010
Total Posts: 6235
26 Dec 2011 03:14 PM
I haven't used LUA for months.

I forgot some of these functions. How can I do it?

I need a function that pick players in game and tell script the name.
Report Abuse
LightedRoblox is not online. LightedRoblox
Joined: 16 Apr 2010
Total Posts: 6235
26 Dec 2011 03:16 PM
Bump.
Report Abuse
LightedRoblox is not online. LightedRoblox
Joined: 16 Apr 2010
Total Posts: 6235
26 Dec 2011 03:18 PM
Could anyone just post?
Report Abuse
LightedRoblox is not online. LightedRoblox
Joined: 16 Apr 2010
Total Posts: 6235
26 Dec 2011 03:18 PM
:l
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
26 Dec 2011 03:19 PM
What's LUA? Launch Under Attack?

Also, no requests.
Report Abuse
LightedRoblox is not online. LightedRoblox
Joined: 16 Apr 2010
Total Posts: 6235
26 Dec 2011 03:20 PM
I simply just forgot. It's not much of request.


Dennisvdz, if you do not even know LUA meaning. Then you must be a HUGE newbie forumer of this forum.
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
26 Dec 2011 03:24 PM
I guess you don't know what LUA means, since only Lua is usual around here.

Lua website:
'Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write "Lua" right!'

And there isn't exactly a pick-random-player-name function.

local p = game.Players:GetChildren()
local name = ""
if #p > 0 then
name = p[math.random(1,#p)
end
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Dec 2011 04:48 PM
"local p = game.Players:GetChildren()
local name = ""
if #p > 0 then
name = p[math.random(1,#p)
end"


Umg! So inefficient!


name = (Game.Players:GetPlayers())[math.random(#Game.Players.NumPlayers)]
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
26 Dec 2011 04:51 PM
Your code doesn't even work at all.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Dec 2011 04:51 PM
Yes it does.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
26 Dec 2011 04:52 PM
"#Game.Players.NumPlayers"

Nice one king, trolololol.
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
26 Dec 2011 04:52 PM
Not really. Take a better look at your #'s.

And what happens when there are 0 players? ERRORRRRR.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Dec 2011 04:53 PM
*
name = (Game.Players:GetPlayers())[math.random(Game.Players.NumPlayers)]


There.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Dec 2011 04:54 PM
If there's 0 players, then there's nobody there to expirience the corruption...
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
26 Dec 2011 04:55 PM
bad argument #1 to 'random' (interval is empty)

Oh dear!
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Dec 2011 04:55 PM
I was originally going to type #Game.Players:GetPlayers(), but then I remembered that NumPlayers existed and forgot to remove the #. Happy??
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Dec 2011 04:55 PM
As I said, if there's 0 players, the game shuts down anyway.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
26 Dec 2011 04:56 PM
"And what happens when there are 0 players? ERRORRRRR."

ply = Game.Players.NumPlayers)
name = (ply > 0) and (Game.Players:GetPlayers())[math.random(ply)].Name or 'No players.'

There Mr. Perfection.
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
26 Dec 2011 04:56 PM
If there's no one in the place, the script shouldn't be running.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
26 Dec 2011 04:56 PM
Ermh n_ñ *

ply = Game.Players.NumPlayers
name = (ply > 0) and (Game.Players:GetPlayers())[math.random(ply)].Name or 'No players.'
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
26 Dec 2011 04:56 PM
Can't help you prefer a core script goes boom.
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
26 Dec 2011 04:57 PM
@Spectrumw: You waste the game's memory. :P

[insert trollface here]
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
26 Dec 2011 04:58 PM
@dennis
Your doesn't even work, so yeah. n_n
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
26 Dec 2011 04:58 PM
Your script would waste more memory.
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
26 Dec 2011 04:59 PM
Nah, I use local instead of global vars.
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