CombradJoin Date: 2009-07-18 Post Count: 11025 |
function randomplayer()
Player = game.Players:GetChildren()
for i = 1,#Player do
Player[i].TeamColor = BrickColor.new("Bright red")
wait(0.5)
end
for i = 1,#Player/2 do
c = math.random(1,#Player)
Player[c].TeamColor = BrickColor.new("Bright red")
wait(0.5)
end
for i = 1,#Player do
Player[i].Character:BreakJoints()
end
end |
|
bloob827Join Date: 2010-08-01 Post Count: 6867 |
Did you call the function |
|
bloob827Join Date: 2010-08-01 Post Count: 6867 |
function randomplayer()
Player = game.Players:GetChildren()
for i = 1,#Player do
Player[i].TeamColor = BrickColor.new("Bright red")
wait(0.5)
end
for i = 1,#Player/2 do
c = math.random(1,#Player)
Player[c].TeamColor = BrickColor.new("Bright red")
wait(0.5)
end
for i = 1,#Player do
Player[i].Character:BreakJoints()
end
end
randomplayer()
This should work. |
|
CombradJoin Date: 2009-07-18 Post Count: 11025 |
Yes I called it. When I tested it...Wait I just noticed...
function randomplayer()
Player = game.Players:GetChildren()
for i = 1,#Player do
Player[i].TeamColor = BrickColor.new("Bright red") -- RED
wait(0.5)
end
for i = 1,#Player/2 do
c = math.random(1,#Player)
Player[c].TeamColor = BrickColor.new("Bright red") -- RED (Should be blue)
wait(0.5)
end
for i = 1,#Player do
Player[i].Character:BreakJoints()
end
end
randomplayer()
|
|
bloob827Join Date: 2010-08-01 Post Count: 6867 |
Ahh.. thats why I didn't change teams. |
|
AgentFirefoxTop 100 PosterJoin Date: 2008-06-20 Post Count: 22404 |
function randomplayer()
local Player = game.Players:GetChildren()
for i = 1,#Player do
local r = math.random(1, #Player)
local rand = Player[r]
if i%2 == 0 then
rand.TeamColor = BrickColor.new("Bright red")
else
rand.TeamColor = BrickColor.new("bright blue")
end
table.remove(Player, r)
end
end
Now this is truly random, and it guarantees an even team every time. :D |
|
CombradJoin Date: 2009-07-18 Post Count: 11025 |
Mine got an even team unless a player joined during it. |
|
AgentFirefoxTop 100 PosterJoin Date: 2008-06-20 Post Count: 22404 |
Yeah but the teams weren't random. A person could've been left on his/her team and another person could've changed teams multiple times. My script guarantees even teams.
I don't see how yours would guarantee an even team. If you look at the logic behind the script, you'll see what I mean. |
|
CombradJoin Date: 2009-07-18 Post Count: 11025 |
Well I can see what you mean slightly. But it complete its purpose... |
|
AgentFirefoxTop 100 PosterJoin Date: 2008-06-20 Post Count: 22404 |
With how many players did you test it? I suggest testing with at least 10 players. You'll find that one team has a high chance of having a team being stacked. |
|
AgentFirefoxTop 100 PosterJoin Date: 2008-06-20 Post Count: 22404 |
"You'll find that one team has a high chance of having a team being stacked."
Morning brain fail...
You'll find that one team has a high chance of being stacked. |
|
CombradJoin Date: 2009-07-18 Post Count: 11025 |
Agent one other question...I made a script that selects a random player from each team. If I re run that script how can I make it so it DOES NOT select the player that was chosen from the previous run? |
|
AgentFirefoxTop 100 PosterJoin Date: 2008-06-20 Post Count: 22404 |
currentPlayers = { }
lastPlayers = { }
function ChooseRandomPlayer(Amount, New)
local A = Amount or 1
local N = New or false
local _P = game.Players:GetPlayers()
currentPlayers = { }
for I = 1, A do
for _ = 1, 1000 do
local R = math.random(1, #_P)
if lastPlayers[I] ~= _P[R] then
table.remove(_P, R)
currentPlayers[I] = _P[R]
lastPlayers[I] = _P[R]
break
end
end
end
return unpack(currentPlayers)
end
I made the currentPlayers table global for a reason. Same goes with the lastPlayers table. |
|