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: table.remove

Previous Thread :: Next Thread 
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
03 Sep 2011 11:26 PM
blah={}
table.insert(blah,"lol")
table.insert(blah,"lol1")
table.insert(blah,"lol2")
table.insert(blah,"lol3")
for i=1,#blah do
print(blah[i])
end
table.remove(blah,"lol3")
for i=1,#blah do
print(blah[i])
end

Output:

lol
lol1
lol2
lol3
Sun Sep 04 00:25:05 2011 - Workspace.Script:9: bad argument #2 to 'remove' (number expected, got string)

I have no idea why it isn't working. The output makes no sense :/

­<'+1 Post. Ujelly?'> IT'S A PEAR http://www.roblox.com/Pear-Hat-item?id=60907280
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
03 Sep 2011 11:26 PM
Never mind, forgot to remove quoted. Dat iz why you don't copy/paste.

Thread closed-

­<'+1 Post. Ujelly?'> IT'S A PEAR http://www.roblox.com/Pear-Hat-item?id=60907280
Report Abuse
eXoguti093 is not online. eXoguti093
Joined: 17 Oct 2008
Total Posts: 1786
03 Sep 2011 11:27 PM
table.remove(blah, 4)
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
03 Sep 2011 11:29 PM
Neber mind, for some reason it doesn't print anyway ?_?

Also, eX, thanks.

­<'+1 Post. Ujelly?'> IT'S A PEAR http://www.roblox.com/Pear-Hat-item?id=60907280
Report Abuse
izzatnasruna is not online. izzatnasruna
Joined: 09 Jun 2009
Total Posts: 1927
03 Sep 2011 11:31 PM
WhatYouWantedToRemove = "lol3"
blah={}
table.insert(blah,"lol")
table.insert(blah,"lol1")
table.insert(blah,"lol2")
table.insert(blah,"lol3")
for i=1,#blah do
print(blah[i])
end
for i,v in pairs(blah) do
if WhatYouWantedToRemove == v then
table.remove(blah,i)
end
end
for i=1,#blah do
print(blah[i])
end
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
03 Sep 2011 11:34 PM
blah={}
table.insert(blah,"lol")
table.insert(blah,"lol1")
table.insert(blah,"lol2")
table.insert(blah,"lol3")
for i=1,#blah do
print(blah[i])
end
for i=1,#blah do
table.remove(blah,i)
end
print("2")
for i=1,#blah do
print(blah[i])
end

Why doesn't that one work?

­<'+1 Post. Ujelly?'> IT'S A PEAR http://www.roblox.com/Pear-Hat-item?id=60907280
Report Abuse
izzatnasruna is not online. izzatnasruna
Joined: 09 Jun 2009
Total Posts: 1927
03 Sep 2011 11:35 PM
Well what does it print?

I prefer this:

blah={}
table.insert(blah,"lol")
table.insert(blah,"lol1")
table.insert(blah,"lol2")
table.insert(blah,"lol3")
for i=1,#blah do
print(blah[i])
end
for i=1,#blah do
table.remove(blah,1)
end
print("2")
for i=1,#blah do
print(blah[i])
end
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Sep 2011 11:35 PM
local blah={}
table.insert(blah, lol, lol1, lol2, lol3)
for i=1,#blah do
print(blah[i])
end
table.remove(blah, 4)
for i=1,#blah do
print(blah[i])
end
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
03 Sep 2011 11:36 PM
I'm trying to add tables, print them, then remove them, and then print them, and it should print nothing, however, the output is:

lol
lol1
lol2
lol3
2
lol1
lol3

­<'+1 Post. Ujelly?'> IT'S A PEAR http://www.roblox.com/Pear-Hat-item?id=60907280
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Sep 2011 11:38 PM
For my script?
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
03 Sep 2011 11:39 PM
For mine. I'm trying to remove everything in the table;

blah={}
table.insert(blah,"lol")
table.insert(blah,"lol1")
table.insert(blah,"lol2")
table.insert(blah,"lol3")
for i=1,#blah do
print(blah[i])
end
for i=1,#blah do
table.remove(blah,i)
end
print("2")
for i=1,#blah do
print(blah[i])
end

Output:

lol
lol1
lol2
lol3
2
lol1
lol3



­<'+1 Post. Ujelly?'> IT'S A PEAR http://www.roblox.com/Pear-Hat-item?id=60907280
Report Abuse
DonnyTheDemented is not online. DonnyTheDemented
Joined: 29 May 2010
Total Posts: 1413
03 Sep 2011 11:39 PM
it doesnt work because you are adding a value to the table, but you didnt mark the positionin the table to add it, so it indexs blah["lol"], but not blah[1] = "lol"

blah={}
table.insert(blah,#blah+1,"lol")
table.insert(blah,#blah+1,"lol1")
table.insert(blah,#blah+1,"lol2")
table.insert(blah,#blah+1,"lol3")
for i=1,#blah do
print(blah[i])
end
for i=1,#blah do
table.remove(blah,1)
end
print("2")
for i=1,#blah do
print(blah[i])
end


probable latepost
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