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: Random Player Value not changing

Previous Thread :: Next Thread 
MisterScripter is not online. MisterScripter
Joined: 24 Sep 2010
Total Posts: 702
29 Dec 2012 09:04 PM
So this script choose a random player every time it is executed, but the value doesnt change after it picks the first random player. It is suppose to choose random players every time it is called but the value still stays the same as the previous player.

p_val = script.Parent.FirstInfected

function InfectPlayer()
bp = game.Players:GetChildren()
for i = 1, #bp do
r = math.random(1, #bp)
end
p_val = bp[r].Name
end

Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
29 Dec 2012 09:08 PM
wut is p_val? A string value? Objectvalue?


> Penguin Power
Report Abuse
MisterScripter is not online. MisterScripter
Joined: 24 Sep 2010
Total Posts: 702
29 Dec 2012 09:09 PM
String Value
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
29 Dec 2012 09:10 PM


    p_val = script.Parent.FirstInfected
    
    function infectPlayer()
      local RandomPlayer = Game.Players:GetPlayers()[math.random(#Game.Players:GetPlayers())]
      p_val.Value = RandomPlayer.Name
    end
    
    infectPlayer()


> Penguin Power
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Dec 2012 09:10 PM
"It is suppose to choose random players"
"random players"

You got it all wrong if that's what you want it to do. This script basically keeps updating the same variable, r, the number of times of how many players are in the game. Then when it's done with it's final iteration it chooses one more player and keeps that as its value.

Report Abuse
MisterScripter is not online. MisterScripter
Joined: 24 Sep 2010
Total Posts: 702
29 Dec 2012 09:10 PM
nevermind i figured it out
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