|
| 19 Feb 2013 04:43 AM |
This minigame script will not work at all, the output given is ' Workspace.Script:5: bad argument #2 to 'random' (interval is empty)' Please could someone offer some help.
while true do local player = game.Players:GetPlayers() local m = math.random(1, 1) local msg = Instance.new("Message") local randomplayer = player[math.random(1,#player)] if #player >= 1 then msg.Parent = game.Workspace msg.Text = "The game is starting" wait(5) msg:Remove() if m == 1 then msg.Parent = game.Workspace msg.Text = "Choosing map." wait(1) msg.Text = "Choosing map.." wait(1) msg.Text = "Choosing map..." wait(1). msg.Text = "A map has been chosen!" wait(3) msg.Text = "The map chosen is..." wait(3) msg.Text = "The Slums!" wait(2) msg.Text = "Selecting Criminal..." randomplayer.TeamColor = BrickColor.new("Bright red") randomplayer.Character:BreakJoints() wait(3) msg.Text = "A criminal has been chosen!" wait(2) msg.Text = "The criminal is "..randomplayer.Name.."" msg.Text = "The police must try to kill the criminal, and the criminal must try to escape before time runs out" wait(8) msg.Text = "The game will commence in:" wait(1) msg.Text = "...3..." wait(1) msg.Text = "..2.." wait(1) msg.Text = ".1." wait(1) msg.Text = "Begin!" player[i].Character:MoveTo(Vector3.new(18, 5, -6)) msg:remove() game.Lighting.Map1:clone().Parent = game.Workspace wait(30) msg.Parent = game.Workspace msg.Text = "Game over!" Workspace.Map1:remove() for i = 1,#player do if player[i].TeamColor == BrickColor.new("Bright red") then player[i].TeamColor = BrickColor.new("Institutional white") wait(3) msg:remove() wait(5) end end end end end |
|
|
| Report Abuse |
|
|
| |
|
H1998
|
  |
| Joined: 30 Mar 2009 |
| Total Posts: 3336 |
|
|
| 19 Feb 2013 06:02 AM |
player[math.random(1,#player)]
It says that your second argument is not valid. There might be something wrong with the :GetPlayers() function you are using? Or, the script is running before player arrive and therefore make it math.random(1,0) |
|
|
| Report Abuse |
|
|
awas3
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 2854 |
|
|
| 19 Feb 2013 06:25 AM |
Try this:
while true do local player = game.Players:GetPlayers() plrs = {} for i = 1, #player do table.insert(plrs, player[i]) end local m = math.random(1, 1) local msg = Instance.new("Message") local randomplayer = plrs[math.random(1,#plrs)] if #player >= 1 then msg.Parent = game.Workspace msg.Text = "The game is starting" wait(5) msg:Remove() if m == 1 then msg.Parent = game.Workspace msg.Text = "Choosing map." wait(1) msg.Text = "Choosing map.." wait(1) msg.Text = "Choosing map..." wait(1). msg.Text = "A map has been chosen!" wait(3) msg.Text = "The map chosen is..." wait(3) msg.Text = "The Slums!" wait(2) msg.Text = "Selecting Criminal..." randomplayer.TeamColor = BrickColor.new("Bright red") randomplayer.Character:BreakJoints() wait(3) msg.Text = "A criminal has been chosen!" wait(2) msg.Text = "The criminal is "..randomplayer.Name.."" msg.Text = "The police must try to kill the criminal, and the criminal must try to escape before time runs out" wait(8) msg.Text = "The game will commence in:" wait(1) msg.Text = "...3..." wait(1) msg.Text = "..2.." wait(1) msg.Text = ".1." wait(1) msg.Text = "Begin!" player[i].Character:MoveTo(Vector3.new(18, 5, -6)) msg:remove() game.Lighting.Map1:clone().Parent = game.Workspace wait(30) msg.Parent = game.Workspace msg.Text = "Game over!" Workspace.Map1:remove() for i = 1,#player do if player[i].TeamColor == BrickColor.new("Bright red") then player[i].TeamColor = BrickColor.new("Institutional white") wait(3) msg:remove() wait(5) end end end end end
l=~/A3\~=l |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2013 06:53 AM |
| Thank you, I will test this. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2013 07:36 AM |
Doesn't work still, output = 'Workspace.Script:9: bad argument #2 to 'random' (interval is empty)'
while true do local player = game.Players:GetPlayers() plrs = {} for i = 1, #player do table.insert(plrs, player[i]) end local m = math.random(1, 1) local msg = Instance.new("Message") local randomplayer = plrs[math.random(1,#plrs)] if #player >= 1 then msg.Parent = game.Workspace msg.Text = "The game is starting" wait(5) msg:Remove() if m == 1 then msg.Parent = game.Workspace msg.Text = "Choosing map." wait(1) msg.Text = "Choosing map.." wait(1) msg.Text = "Choosing map..." wait(1). msg.Text = "A map has been chosen!" wait(3) msg.Text = "The map chosen is..." wait(3) msg.Text = "The Slums!" wait(2) msg.Text = "Selecting Criminal..." wait(3) msg.Text = "A criminal has been chosen!" wait(2) msg.Text = "The criminal is "..randomplayer.Name.."" randomplayer.TeamColor = BrickColor.new("Bright red") randomplayer.Character:BreakJoints() wait(2) msg.Text = "The police must try to kill the criminal, and the criminal must try to escape before time runs out" wait(8) msg.Text = "The game will commence in:" wait(1) msg.Text = "...3..." wait(1) msg.Text = "..2.." wait(1) msg.Text = ".1." wait(1) msg.Text = "Begin!" player[i].Character:MoveTo(Vector3.new(18, 5, -6)) msg:remove() game.Lighting.Map1:clone().Parent = game.Workspace wait(30) msg.Parent = game.Workspace msg.Text = "Game over!" Workspace.Map1:remove() for i = 1,#player do if player[i].TeamColor == BrickColor.new("Bright red") then player[i].TeamColor = BrickColor.new("Institutional white") wait(3) msg:remove() wait(5) end end end end end |
|
|
| Report Abuse |
|
|
H1998
|
  |
| Joined: 30 Mar 2009 |
| Total Posts: 3336 |
|
|
| 19 Feb 2013 08:45 AM |
| You kind of ignored what I said |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2013 11:17 AM |
| No I didn't. I didn't post it, but I put the whole script between an onEntered function, and that fixed it. |
|
|
| Report Abuse |
|
|
cart6157
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2194 |
|
|
| 19 Feb 2013 11:20 AM |
| Put a wait() in front of the script |
|
|
| Report Abuse |
|
|
cart6157
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2194 |
|
|
| 19 Feb 2013 11:21 AM |
Or this:
while true do wait() local player = game.Players:GetPlayers() if #player > 0 then local m = math.random(1, 1) local msg = Instance.new("Message") local randomplayer = player[math.random(1,#player)] if #player >= 1 then msg.Parent = game.Workspace msg.Text = "The game is starting" wait(5) msg:Remove() if m == 1 then msg.Parent = game.Workspace msg.Text = "Choosing map." wait(1) msg.Text = "Choosing map.." wait(1) msg.Text = "Choosing map..." wait(1). msg.Text = "A map has been chosen!" wait(3) msg.Text = "The map chosen is..." wait(3) msg.Text = "The Slums!" wait(2) msg.Text = "Selecting Criminal..." randomplayer.TeamColor = BrickColor.new("Bright red") randomplayer.Character:BreakJoints() wait(3) msg.Text = "A criminal has been chosen!" wait(2) msg.Text = "The criminal is "..randomplayer.Name.."" msg.Text = "The police must try to kill the criminal, and the criminal must try to escape before time runs out" wait(8) msg.Text = "The game will commence in:" wait(1) msg.Text = "...3..." wait(1) msg.Text = "..2.." wait(1) msg.Text = ".1." wait(1) msg.Text = "Begin!" player[i].Character:MoveTo(Vector3.new(18, 5, -6)) msg:remove() game.Lighting.Map1:clone().Parent = game.Workspace wait(30) msg.Parent = game.Workspace msg.Text = "Game over!" Workspace.Map1:remove() for i = 1,#player do if player[i].TeamColor == BrickColor.new("Bright red") then player[i].TeamColor = BrickColor.new("Institutional white") wait(3) msg:remove() wait(5) end end end end end end |
|
|
| Report Abuse |
|
|
awas3
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 2854 |
|
|
| 19 Feb 2013 03:14 PM |
| Maybe that may change somethng but he has got a wait(5) at the end of the script |
|
|
| Report Abuse |
|
|