|
| 26 Aug 2014 07:51 PM |
HDD = script.Parent.Parent.Parent.Parent["Hard Drive"]
Num1 = 0 Num2 = 0 Folders = {} Meshes = {}
script.Parent.Changed:connect(function() if script.Parent.Visible == true then for i, v in pairs(HDD:GetChildren()) do Folders[i] = v.Name end for i, v in pairs(HDD:findFirstChild(Folders[i])) do for o, b in pairs(v:GetChildren()) do Game:GetService("ContentProvider"):Preload(b.MeshId) script.Parent.Msg.Text = Folders[i].."("..i..")|File".."("..o.."/"..#v..")" end end
end end)
---------------------------------
19:50:09.684 - Argument 1 missing or nil 19:50:09.685 - Script 'Workspace.Model.Monitor.Screen.BootProgram.Initialize', Line 13 19:50:09.685 - Stack End 19:50:09.685 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 07:59 PM |
I made this earlier:
TargetPath = script.Parent
for i, v in pairs(TargetPath:GetChildren()) do if v.className == "Configuration" then for o, b in pairs(v:GetChildren()) do if b.className == "SpecialMesh" then Game:GetService("ContentProvider"):Preload(b.MeshId) end end end end
and it worked, but it lacked an animation so I tried to rewrite it as the original post, the idea being that as it preloaded, it would change the text on a surface gui to display the following:
Folder(#)|File(#/#)
Apparently I messed up somewhere but I don't know where. There's so much going on that my brain is all upside down and stuff. D: |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:02 PM |
why is there an "end" in
for i, v in pairs(HDD:GetChildren()) do Folders[i] = v.Name end
this ends the function, and is no longer usable |
|
|
| Report Abuse |
|
|
cingwar73
|
  |
| Joined: 16 Aug 2009 |
| Total Posts: 358 |
|
|
| 26 Aug 2014 08:03 PM |
| That doesnt end the function, it ends the if statement about it being visible. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:04 PM |
| I'm not entirely sure, but in the first for loop when it's supposed to create the Folders table with the names of the objects, it puts their names in the table without creating actual strings. I don't know how to create strings that way because apparently putting a quotation mark between 2 quotations doesn't type a quotation. |
|
|
| Report Abuse |
|
|
cingwar73
|
  |
| Joined: 16 Aug 2009 |
| Total Posts: 358 |
|
| |
|
|
| 26 Aug 2014 08:06 PM |
Yes
for i, v in pairs(HDD:GetChildren()) do Folders[i] = v.Name end
This for loop just maps out the Folders table. The second for loop is supposed to call from it and the third calls for the children of whatever number the second is on.
I know it works, but for some reason the first loop isn't creating strings. It's just sticking the folder names into the table. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:06 PM |
generic for's are functions
They are composed of looping over a generic statement
for _,v in pairs(game.Workspace:GetChildren()) do -- returns a table |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:08 PM |
HDD = script.Parent.Parent.Parent.Parent["Hard Drive"]
Num1 = 0 Num2 = 0 Folders = {} Meshes = {}
script.Parent.Changed:connect(function() if script.Parent.Visible == true then for u, c in pairs(HDD:GetChildren()) do Folders[c] = "'" ..c.Name.."'" end for i, v in pairs(HDD[Folders[i]]) do for o, b in pairs(v:GetChildren()) do Game:GetService("ContentProvider"):Preload(b.MeshId) script.Parent.Msg.Text = Folders[i].."("..i..")|File".."("..o.."/"..#v..")" end end
end end)
--------------------------
20:07:55.190 - Workspace.Model.Monitor.Screen.BootProgram.Initialize:13: bad argument #2 to '?' (string expected, got nil) 20:07:55.191 - Script 'Workspace.Model.Monitor.Screen.BootProgram.Initialize', Line 13 20:07:55.192 - Stack End 20:07:55.193 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:11 PM |
| I didn't ask about global tables. I made it the way I wanted, I just need help getting it working. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:25 PM |
Added a wait command for the animation delay and fixed another error I saw that would have been displayed after this one got fixed. Also separated the functions to make it easier to read.
HDD = script.Parent.Parent.Parent.Parent["Hard Drive"]
Num1 = 0 Num2 = 0 Folders = {} Meshes = {}
script.Parent.Changed:connect(function() if script.Parent.Visible == true then
for u, c in pairs(HDD:GetChildren()) do Folders[u] = "'" ..c.Name.."'" end
for i, v in pairs(HDD[Folders[i]]) do for o, b in pairs(v:GetChildren()) do Game:GetService("ContentProvider"):Preload(b.MeshId) script.Parent.Msg.Text = Folders[i].."("..i..")|File".."("..o.."/"..#v..")" wait() end end
end end) |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:42 PM |
What I think I know is this:
20:28:04.273 - Workspace.Model.Monitor.Screen.BootProgram.Initialize:14: bad argument #2 to '?' (string expected, got nil) 20:28:04.274 - Script 'Workspace.Model.Monitor.Screen.BootProgram.Initialize', Line 14 20:28:04.276 - Stack End 20:28:04.277 - Disconnected event because of exception
has to do with this line:
for i, v in pairs(HDD[Folders[i]]) do
Which leads me to believe that this function:
for u, c in pairs(HDD:GetChildren()) do Folders[u] = "'" ..c.Name.."'" end
Is not creating the strings in the tables. If I had to guess, it's doing this:
Folders = {eg1, eg2, eg3}
instead of:
Folders = {"eg1", "eg2", "eg3"}
on the other hand, the error is saying that it's expecting a string, but is finding nothing in the table itself. So it could be that the first for loop isn't adding the folders to the table at all.
It's the same concept as this script I made last night:
NumberCap = nil CounterCap = nil NumberTab = {} if NumberCap == nil or CounterCap == nil then return end for i = 1, NumberCap, 1 do NumberTab[i] = 0 end for i = 1, CounterCap, 1 do local Counter = math.random(1, NumberCap) NumberTab[Counter] = NumberTab[Counter] + 1 wait() for o = 1, 20, 1 do print() end print("------------------------------") print("Calculating Number("..i..")") print("------------------------------") end wait(1) print("Calculations finished.") wait(1) print("Please wait while your results are printed.") wait(3) for o = 1, 20, 1 do print() end for i = 1, NumberCap, 1 do print("The number "..i.." has appeared "..NumberTab[i].." times.") end
You can keep this script if you want. It's for anyone who wants it. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:55 PM |
| No matter what I do it's still giving me the same bullcrap error. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 08:59 PM |
local Files = HDD:GetChildren() for i = 1, #Files, 1 do if Files[i].className == "Configuration" then Folders[i] = Files[i].Name end end
Different method, same error. |
|
|
| Report Abuse |
|
|
iiEssence
|
  |
| Joined: 18 Jun 2014 |
| Total Posts: 3467 |
|
|
| 26 Aug 2014 09:03 PM |
| From original post, Folders[i] is nil. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2014 09:08 PM |
| Yeah that's what I've been saying. It's like the first for loop refuses to put the names into the table. |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Aug 2014 10:04 PM |
I added a print command to it to see what was going on and it is indeed adding the names to the table
HDD = script.Parent.Parent.Parent.Parent["Hard Drive"]
Num1 = 0 Num2 = 0 Folders = {} Meshes = {}
script.Parent.Changed:connect(function() if script.Parent.Visible == true then
for u, c in pairs(HDD:GetChildren()) do if c.className == "Configuration" then Folders[u] = c.Name print(Folders[u]) end end
for i, v in pairs(HDD[Folders[i]]) do for o, b in pairs(v:GetChildren()) do Game:GetService("ContentProvider"):Preload(b.MeshId) script.Parent.Msg.Text = Folders[i].."("..i..")|File".."("..o.."/"..#v..")" wait() end end
end end) |
|
|
| Report Abuse |
|
|