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: The random script(Help)

Previous Thread :: Next Thread 
datdude3 is not online. datdude3
Joined: 23 Apr 2010
Total Posts: 577
05 Mar 2012 05:12 PM
So what would the script be if I had 5 games and I wanted roblox to choose them randomly?
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
05 Mar 2012 05:15 PM
If you mean maps then you would use do

--Psuedo code
maps = getAllMaps()
math.randomseed(tick())
newMap = maps[randomNumber]
Clone newMap into workspace
Report Abuse
datdude3 is not online. datdude3
Joined: 23 Apr 2010
Total Posts: 577
05 Mar 2012 05:16 PM
That is useful but I'm talking about changing player everytime for the game
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
05 Mar 2012 05:19 PM
Still am not understanding you . . .
Report Abuse
datdude3 is not online. datdude3
Joined: 23 Apr 2010
Total Posts: 577
05 Mar 2012 05:22 PM
Ok so lets say this one guy named bob was in my game and was playing how would I make a different player the role of what bob had?
Report Abuse
Rangerko is not online. Rangerko
Joined: 12 Sep 2008
Total Posts: 126
05 Mar 2012 05:28 PM
...What.
Report Abuse
datdude3 is not online. datdude3
Joined: 23 Apr 2010
Total Posts: 577
05 Mar 2012 05:32 PM
Its like tag it selects random players to be the enemy or something
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
05 Mar 2012 05:47 PM
All right, I'll show you how to find a random player, but you take care of what to do with it.

local rplr = game.Players:GetPlayers()[math.random(#game.Players:GetPlayers())]

Now the variable `rplr` is a random player in the server.

You now have +10 INT from this post. Oh, by the way, Like an __AWESOME__ boss-
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
06 Mar 2012 03:40 PM
Make sure that is declared inside the function, or else it will only get a random player once instead of finding a new one every time the function is called.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
06 Mar 2012 04:02 PM
@epicfail - What function? I didn't declare any. :/

You now have +10 INT from this post. Oh, by the way, Like an __AWESOME__ boss-
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
06 Mar 2012 04:03 PM
Excluding math.random, that is.

You now have +10 INT from this post. Oh, by the way, Like an __AWESOME__ boss-
Report Abuse
top1 is not online. top1
Joined: 05 Mar 2009
Total Posts: 115
06 Mar 2012 04:09 PM
The creator probably wants more random people and then he would make a function fduh..
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
06 Mar 2012 04:21 PM
@Top - I know. I was kidding, epicfail said 'the function', but there was none. Anyways, I did say he could take it from what I gave him, in case you didn't read that. Though I suppose I'll post a function for that, too...

    function RPlayers()
        return game.Players:GetPlayers()[math.random(#game.Players:GetPlayers())]
    end

Now the function `RPlayers` will return a random player. So, here's an example of its use:

    local rp1 = RPlayers()
    local rp2 = RPlayers()

Now rp1 and rp2 are two random players. They might be the same though. You take care of that.

You now have +10 INT from this post. Oh, by the way, Like an __AWESOME__ boss-
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
06 Mar 2012 04:37 PM
@ElectricBlaze; I was referring to when the OP uses it. Not what you posted.
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