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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
| |
|
Luminak
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
| |
|
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
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
| |
|
Luminak
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
| |
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
| |
|
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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
| |
|
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
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
|
| 18 May 2015 01:48 PM |
| can somebody help and make sure it works |
|
|
| Report Abuse |
|
|
9draco
|
  |
| Joined: 13 Nov 2010 |
| Total Posts: 5841 |
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
| |
|