miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Jan 2012 09:24 PM |
number = math.random(#_G.myTable) game.Players[_G.myTable[number]].Character.Torso.CFrame = CFrame.new(-81.5, 1, 92) table.insert(_G.myTable2,_G.myTable[number]) table.remove(_G.myTable,number) wait() game.Players[_G.myTable[number]].Character.Torso.CFrame = CFrame.new(-32.5, 1, 92) table.insert(_G.myTable2,_G.myTable[number]) table.remove(_G.myTable,number)
Output Workspace.Countdown round:16: bad argument #2 to '?' (string expected, got nil)
Does this error because they have both of the same name? I'm in start server mode when testing this and the first CFrame works but not the second...Same name?That why?
And here is the script for the Players going into the table.
This script works. _G.myTable = {} game.Players.PlayerAdded:connect(function(p) table.insert(_G.myTable,p.Name) end) game.Players.PlayerRemoving:connect(function(r) for i,v in next, _G.myTable do if v == r.Name then table.remove(_G.myTable, i) break end end end)
|
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:25 PM |
O_o Needs more descriptive table names... And where's line 16?
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
KingBoo
|
  |
| Joined: 16 Jul 2007 |
| Total Posts: 8495 |
|
|
| 09 Jan 2012 09:25 PM |
"number = math.random(#_G.myTable)"
It needs to be;
number = math.random(0, #_G.myTable) |
|
|
| Report Abuse |
|
|
KingBoo
|
  |
| Joined: 16 Jul 2007 |
| Total Posts: 8495 |
|
|
| 09 Jan 2012 09:26 PM |
Darn; I keep forgetting this is lua not c++..
Replace the 0 in my fix with a 1. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Jan 2012 09:28 PM |
game.Players[_G.myTable[number]].Character.Torso.CFrame = CFrame.new(-32.5, 1, 92)
That's line 16
What I want it to do is teleports one player, then that same player teleported gets inserted to a table and removed to a table. Same after the wait. That only happens to one player though. |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:28 PM |
| Does the table contain strings or numbers? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Jan 2012 09:28 PM |
@epicfail
The table contains players.. |
|
|
| Report Abuse |
|
|
KingBoo
|
  |
| Joined: 16 Jul 2007 |
| Total Posts: 8495 |
|
|
| 09 Jan 2012 09:29 PM |
Miz, replace number = math.random(#_G.myTable)
with
number = math.random(1, #_G.myTable)
Tell me if that works. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Jan 2012 09:30 PM |
| For both or after the wait? |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:30 PM |
| KingBoo, you can give it only 1 param. |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
|
| 09 Jan 2012 09:31 PM |
| @King the first argument is automatically one if you don't fill it in |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:31 PM |
@kingkiller whatchoo talkin' 'bout? for i = 1,10 do print(math.random(1,10)) end
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]-
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Jan 2012 09:32 PM |
I want
Two players teleport, two players removed and inserted from a table. That only works for one player. |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:32 PM |
| Don't worry about what KingBoo said, it's fine. But it's kind of hard to tell what the actual mistake is, because you gave vague variable names, etc. |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:32 PM |
"@kingkiller whatchoo talkin' 'bout? for i = 1,10 do print(math.random(1,10)) end"
I never said you can't have two. I'm saying that this:
for i = 1,10 do print(math.random(10)) end
would have the same effects. |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:33 PM |
"@King the first argument is automatically one if you don't fill it in"
There is a misunderstanding. I KNOW THIS. I'm trying to TELL that to KingBoo, who doesn't know that. |
|
|
| Report Abuse |
|
|
KingBoo
|
  |
| Joined: 16 Jul 2007 |
| Total Posts: 8495 |
|
|
| 09 Jan 2012 09:33 PM |
Oh, wow. When did they do this?
By the way, if the table includes actual players, then just do
_G.myTable[number].Character.CFrame = CFrame.new(Blah,Blah,Blah)
No need for the game.Players |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Jan 2012 09:35 PM |
"because you gave vague variable names"
What you mean :l |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:35 PM |
| So the table contains ObjectValues of the players, right? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Jan 2012 09:36 PM |
@kingboo
You ain't helpin :p |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
| |
|
KingBoo
|
  |
| Joined: 16 Jul 2007 |
| Total Posts: 8495 |
|
|
| 09 Jan 2012 09:37 PM |
Well, you quite frankly aren't telling us much.
Is the table full of actual players, like;
myTable = {game.Players.KingBoo}
or is it;
myTable = {"KingBoo"} |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
|
| 09 Jan 2012 09:37 PM |
*King's Post*
_G.myTable = {} game.Players.PlayerAdded:connect(function(p) table.insert(_G.myTable,p) end) game.Players.PlayerRemoving:connect(function(r) for i,v in next, _G.myTable do if v == r.Name then table.remove(_G.myTable, i) break end end end)
number = math.random(#_G.myTable) _G.myTable[number].Character.Torso.CFrame = CFrame.new(-81.5, 1, 92) table.insert(_G.myTable2,_G.myTable[number]) table.remove(_G.myTable,number) wait() _G.myTable[number].Character.Torso.CFrame = CFrame.new(-32.5, 1, 92) table.insert(_G.myTable2,_G.myTable[number]) table.remove(_G.myTable,number)
|
|
|
| Report Abuse |
|
|
|
| 09 Jan 2012 09:39 PM |
@smurf279
What does "for index, value in next, table" do? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 09 Jan 2012 09:39 PM |
@kingboo
myTable2 = {"miz656","kingboo"}
Like that
@smurf
What did you change differently?
|
|
|
| Report Abuse |
|
|