|
| 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 |
|
|
|
| 29 Dec 2012 09:08 PM |
wut is p_val? A string value? Objectvalue?
> Penguin Power |
|
|
| Report Abuse |
|
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 29 Dec 2012 09:10 PM |
nevermind i figured it out
|
|
|
| Report Abuse |
|
|