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 » Scripters
Home Search
 

Re: How would I do this

Previous Thread :: Next Thread 
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 10:49 AM
How do I make it so it counts numplayers and chooses one player from it

example Ik this wont work but it gives u an idea:

local p = game.Players.NumPlayers

math.random(p, 1)
then what happens
and yes I know it wont work but it's an idea, so please help
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
18 May 2015 10:51 AM
players = game.Players:GetPlayers()
random_player = players[math.random(#players)]
Report Abuse
Intern33t is not online. Intern33t
Joined: 19 Nov 2010
Total Posts: 1530
18 May 2015 10:51 AM
local r = math.random(1, game.Players.NumPlayers)

local l = game.Players:GetPlayers()

local CHOSENPLAYER = l[r]
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
18 May 2015 10:51 AM
Here is how:

local Players = game.Players:GetPlayers() --This is to get a table of players/
local RandomPlayer = Players[math.random(1, #Players)] --This uses the math.random function to choose 1 player from the table.
print(RandomPlayer.Name.." has been chosen.") --This tells us who was chosen.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 10:58 AM
@power it doesn't work
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 11:00 AM
None of those work
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 11:04 AM
anybody that tells me I'll give 50 robux
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 11:10 AM
halpp
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 11:17 AM
b
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
18 May 2015 11:39 AM
Make sure it's a Server-Script.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
18 May 2015 11:44 AM
local Players = game:GetService("Players")
local RandomPlayer = Players[math.random(#Players)]


~Master bug finder twitch.tv/ROBLOX/c/4691695 14:07-14:25~
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
18 May 2015 11:45 AM
local Players = game:GetService("Players"):GetPlayers()
local RandomPlayer = Players[math.random(#Players])

fixed


~Master bug finder twitch.tv/ROBLOX/c/4691695 14:07-14:25~
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
18 May 2015 11:45 AM
nvm, just use roflbread's, he has good tasting bread and his script works.


~Master bug finder twitch.tv/ROBLOX/c/4691695 14:07-14:25~
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 11:56 AM
power it is
Report Abuse
daireb is not online. daireb
Joined: 16 Nov 2012
Total Posts: 726
18 May 2015 12:19 PM
function ranPlayer()
local players = game.Players:GetChildren()
return players[math.random(1,#players)]

If this doesn't work then you are completely screwed, because the Kraken has already struck down your Roblox.
#ObscureKSPreference
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 12:52 PM
Can somebody tell me how to make it so like for example it gives you a gear from lighting
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
18 May 2015 01:08 PM
Wait.. Wait..

Don't use Lighting.. Use ServerStorage/ReplicatedStorage.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 01:42 PM
power still doesn't work
Report Abuse
vacha is not online. vacha
Joined: 06 Jan 2011
Total Posts: 1993
18 May 2015 01:44 PM
You need more than 1 players for power's first script to work..


while true do the do
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 01:48 PM
can somebody help and make sure it works
Report Abuse
9draco is not online. 9draco
Joined: 13 Nov 2010
Total Posts: 5841
18 May 2015 01:49 PM
Learn, skrub.
Report Abuse
vacha is not online. vacha
Joined: 06 Jan 2011
Total Posts: 1993
18 May 2015 01:51 PM
if game.Players.NumPlayers>1 then
local playas = game.Players:GetPlayers()
local randomplayer = playas[math.random(1,#playas)]
print(playas[randomplayer].Name)
else
print("Only 1 player")
end


while true do the do
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
18 May 2015 01:53 PM
My script was an out-of-the-box script... You don't need to edit it...

All you need to do is put it in a NORMAL-SCRIPT, in ServerScriptService or Workspace (recommend ServerScriptService for security) and it should print out something, even if there is 1 player.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 01:56 PM
vacha it works pretty much but if theres more then 1 player nothing happens
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
18 May 2015 01:57 PM
powre it just says error
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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