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: 2 random players

Previous Thread :: Next Thread 
misterhup is not online. misterhup
Joined: 07 Jul 2010
Total Posts: 280
28 Jul 2015 11:38 PM
I want to detect 2 random players and change an Int Value in them (game.Players) that has been added already...How do I find them?
Report Abuse
misterhup is not online. misterhup
Joined: 07 Jul 2010
Total Posts: 280
28 Jul 2015 11:39 PM
Basically every player in my game has an Int Value equals to 1. I want to change it to 2 to just 2 random players. How do I do that?
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
28 Jul 2015 11:41 PM
local P1 = game.Players:GetChildren()[math.random(1,game.Players.NumPlayers)]
local P2 = game.Players:GetChildren()[math.random(1,game.Players.NumPlayers)]

P1.IntValue.Value = 2
P2.IntValue.Value = 2

there's the crude way
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
28 Jul 2015 11:42 PM
^but they can be the same player


robo is love robo is life
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
28 Jul 2015 11:44 PM
That's why I said "crude"

You can also do

local P1 = game.Players:GetChildren()[math.random(1,game.Players.NumPlayers)]
local P2 = nil

repeat P2 = game.Players:GetChildren()[math.random(1,game.Players.NumPlayers)] wait() until P2 and P2 ~= P1

P1.IntValue.Value = 2
P2.IntValue.Value = 2


Still crude though
Report Abuse
misterhup is not online. misterhup
Joined: 07 Jul 2010
Total Posts: 280
28 Jul 2015 11:45 PM
Thx, It works
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