Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Expected Table, instead got nil?

Asked by 8 years ago
--Main Script
--\\ Nicknames
local Frame = script.Parent.PositioningFrame
local Tabs = require(script.Get)
--\\ Main Code
    for _,v in pairs(Tabs.Get) do
        print('Tab name is:' ..v)
    end
--Module
local Get = {}
    local Find = script.Parent.Parent.PositioningFrame:GetChildren()
    for i = 1, #Find do
        if Find[i].ClassName == 'TextButton' then
            local add = table.insert(Get, Find[i].Name)
        end
    end
return Get

I'm not 100% used to how Modules work, so bare with me if I ask silly questions when you answer.

1
Please post your exact error. GoldenPhysics 474 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

Modules

Most of what you wrote is valid except for one line, so I'm not gonna lecture you on modules. But I will say that when you require a module, the value it returns is passed directly to where it was required - much like returning a value through a function, and therein lies the source of your problem .


Line 6: You try to index Tabs for table Get, when Tabs represents Get. Instead of saying Tags.Get, just pass Tabs as an argument to pairs in your for loop and you should be clear on that issue.

-- Example
for i,v in pairs(Tabs) do
    -- etc
end
0
Thank you very much! Vingam_Securis 213 — 8y
0
Also, I'd like if you -could- lecture me on Modules, I only know the 'function' part of stuff... I did the table as an experiment and that shows how much I know! XD Vingam_Securis 213 — 8y
Ad

Answer this question