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: First part works, second doesn't.

Previous Thread :: Next Thread 
miz656 is not online. 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
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
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 is not online. 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 is not online. 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 is not online. 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
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
09 Jan 2012 09:28 PM
Does the table contain strings or numbers?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Jan 2012 09:28 PM
@epicfail

The table contains players..
Report Abuse
KingBoo is not online. 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 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Jan 2012 09:30 PM
For both or after the wait?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
09 Jan 2012 09:30 PM
KingBoo, you can give it only 1 param.
Report Abuse
smurf279 is not online. 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
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
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 is not online. 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
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
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
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
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
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
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 is not online. 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 is not online. 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
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
09 Jan 2012 09:35 PM
So the table contains ObjectValues of the players, right?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Jan 2012 09:36 PM
@kingboo

You ain't helpin :p
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Jan 2012 09:36 PM
@epic

Yes.
Report Abuse
KingBoo is not online. 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 is not online. 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
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
09 Jan 2012 09:39 PM
@smurf279

What does "for index, value in next, table" do?
Report Abuse
miz656 is not online. 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
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