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 » Scripters
Home Search
 

Re: table.Insert Problem

Previous Thread :: Next Thread 
blackeye61 is not online. blackeye61
Joined: 16 Aug 2010
Total Posts: 342
14 Jul 2017 09:59 PM
So, before I go on just take a look at the script I am having trouble with
itemsbought = {}
for i,v in pairs(script.Parent.Parent.Boxes:GetChildren()) do
print (v.Name)
print (v.Value)
local id = v:FindFirstChildOfClass("IntValue")
print(id.Value)
table.insert(itemsbought, id.Value, v.Value)
end
print(itemsbought[1])
print(itemsbought[2])
-- this goes on 4 more times and there is more script above and below, but this should do

Essentially, every single time, itemsbought[2] is nil, but in the loop id.Value is not nil, v.Value isn't nil before and after the loop and there is no other id values with a value of 2, every other value is printing fine. Any ideas on what is wrong?


Report Abuse
blackeye61 is not online. blackeye61
Joined: 16 Aug 2010
Total Posts: 342
14 Jul 2017 10:07 PM
bump
(printing a whole ton of different possibilities trying to find something that would make that nil)


Report Abuse
BaiYuni is not online. BaiYuni
Joined: 09 Oct 2009
Total Posts: 2861
14 Jul 2017 10:09 PM
Wait what?

table.insert has only 3 parameters?
Report Abuse
blackeye61 is not online. blackeye61
Joined: 16 Aug 2010
Total Posts: 342
14 Jul 2017 10:10 PM
It may have more, but they aren't required in this instance


Report Abuse
blackeye61 is not online. blackeye61
Joined: 16 Aug 2010
Total Posts: 342
14 Jul 2017 10:11 PM
Just checked wiki, only three. the table, the order and the value


Report Abuse
BaiYuni is not online. BaiYuni
Joined: 09 Oct 2009
Total Posts: 2861
14 Jul 2017 10:14 PM
Oops mb, nvm.
Report Abuse
blackeye61 is not online. blackeye61
Joined: 16 Aug 2010
Total Posts: 342
14 Jul 2017 10:14 PM
Going to put them all in one at a time without the loop, going to see if that helps


Report Abuse
blackeye61 is not online. blackeye61
Joined: 16 Aug 2010
Total Posts: 342
14 Jul 2017 10:21 PM
Okay, I did it without the loop and it works fine, I think it's because the value was being shifted to the beginning of the table leading to at least one value being replaced.


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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