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: Player Picker

Previous Thread :: Next Thread 
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
07 May 2014 12:45 PM
wat if I say;
Beast = Math.Random(1, #Player)

would that line actually mean that the Beast is equal to the Player that was picked, so I could then do stuff like BeastSpawn Bricks and stuff?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
07 May 2014 12:51 PM
Player = game.Players:GetPlayers()
Beast = Player[math.random(1,#Player)]

like that,yes
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
07 May 2014 01:24 PM
math.random(#Player)

is also possible right?


Anyway,
STOP COPYING.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
07 May 2014 01:48 PM
yes
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
07 May 2014 03:52 PM
thnx islandmaker, I think I know the other text... also, for me putting a Mesh into the persons Torso, how would I clone() it properly? cos I get so confused with these things sometimes...
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
07 May 2014 03:58 PM
local players = game.Players:GetPlayers()
local beast = players[math.random(#players)]
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
07 May 2014 05:10 PM
thnx guys, also, how would I put him onto a Team? like Bright Red
Report Abuse
PlaceRebuilder is not online. PlaceRebuilder
Joined: 29 Apr 2008
Total Posts: 1056
07 May 2014 05:16 PM
Using math.random to pick players are highly unfair.
Math random will NOT give you a fair amount of randomness. One player will be Beast 10 times in a row before any other gets a chanse.

For me I choose to go with
local players = game.Players:GetPlayers()
local v = game.Workspace.DistributedGameTime%#players+1
Beast = players[v]

Works much better in these cases..
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
07 May 2014 05:40 PM
lol I was gonna ask about that, but I thought that most people will refuse to help... and btw, I have a leaderstat called RW (Rounds Waited) and I wwould like that to be the chance of the player becoming the beast, and then wen he becomes the beast, his RW is reset inside the system so he doesnt keep becoming the beast over and over, but the visual RW (on the leaderboard) would stay the same for showwing of or maybe to see how much u've played...
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
07 May 2014 05:40 PM
howw wwould I do that?
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
08 May 2014 11:01 AM
bump
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
08 May 2014 05:51 PM
BUMP GUYS!
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 06:06 AM
guys...
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
09 May 2014 06:11 AM
Not gonna help u copy games.
Report Abuse
AetherShotgun is not online. AetherShotgun
Joined: 17 Mar 2014
Total Posts: 656
09 May 2014 06:12 AM
local Players = game.Players:GetPlayers() --Get Players
local TopHat = { } --Don't question this magic :3

for _, Player in pairs(Players) do --Repeat through players
for i=1, Player.leaderstats.RW.Value do --Repeat steps #of Rounds Waited...
TopHat[#TopHat + 1] = Player --Add player to tophat #of rounds waited.
end
end

local Beast = TopHat[math.random(1, #TopHat)] --Get random player

print(Beast.Name) --Beast will return a player value.

--Remember to set rounds waited back to 1 all the time, otherwise it seems it would be unstable.
Report Abuse
PlaceRebuilder is not online. PlaceRebuilder
Joined: 29 Apr 2008
Total Posts: 1056
09 May 2014 06:13 AM
local players = game.Players:GetPlayers()
local maxvalue = 0;
for i = 1,#players do
maxvalue = maxvalue + players[i].RW.Value
end

local v = game.Workspace.DistributedGameTime%maxvalue+1
local currentmax = 0;
for i = 1,#players do
currentmax = currentmax + players[i].RW.Value
if (v < currentmax) then
Beast = players[i]
end
end

havnt tested it but i think u get the idea
Report Abuse
TigerCaptain is not online. TigerCaptain
Joined: 08 Aug 2011
Total Posts: 369
09 May 2014 06:19 AM
to get a random player, whether for beast, choosing a random map, or heck, choosing a random name like Alpha, Delta, Gamma, Kilo, etc., you need to do one of two things.

1) Set up a table.

to set up a table, you can use :GetChildren() if its an object, or,
t = {"Alpha","Delta","Gamma","Kilo"}
is a name table.

2) choose a random object within that table.

to choose a random object, you use math.random(min,max)
before we relate that to tables, you can access things inside of tables with numbers.

a = t[1] -- alpha
d = t[2] -- delta
g = t[3] -- gamma

and so on.
Using that same method, if we want a random thing inside the table, we use math.random(min,#stuff in that table)

t[math.random(1,#t)]

Thus, in conclusion, you can get all the players in a table using :GetChildren(), and then pick a random one like so:


players=game.Players:GetChildren()
killer = players[math.random(1,#players)]
print(killer.Name.." is the killer!")



Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 08:08 AM
thnx all u guys :D and those who say I copy... well I dont! loleris inspired me to do something like his, but different... also, I want a Mesh to be inserted into the Beast, how would I do that? cos am a lil confused with clone() cos sometimes it sAys clone().Parent but if I were to make a new Instance and copy the ID and TextureID then I wouldnt know if my script was right or wrong... and if I wanted to select also, like there's juggernaut, I wanna have Enforcer in my Game... with different Chance Stats though...
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 08:10 AM
would I just add another paragraph (but not GetPlayers() again cos it was already done) and just instead of Beast type Enforcer and for chance type other stuff?
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 08:37 AM
bump u guys XD
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 08:38 AM
also, how would I take the Title of the Beast and Enforcer after the Round has ended?
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 09:10 AM
for the Beats Mesh, do I do like
local Beast = game.Players.GetBeastFromCharacter?
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 09:56 AM
plz guys answer...
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 12:09 PM
bad argument #2 to 'random' (interval is empty)
thats for the
local Beast = TopHat[math.random(1, #TopHat)]
cos the thing on top was
local TopHat = { }
and nothing on top of it cos its not a thing that gets something, it only indicates howw much chance u got... so wat will I do to remove this problem???
Report Abuse
AndriusKapitanovas is not online. AndriusKapitanovas
Joined: 26 Jan 2013
Total Posts: 474
09 May 2014 12:24 PM
plz guys, am so close to finishing the Basic stuff in this Game... only a lil left...
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