Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Expected Table, instead got nil?

--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 comment

1

Please post your exact error.

1 answer

✓ Accepted answer

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

2 comments

0

Thank you very much!

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

This discussion is preserved as it was. New answers, comments, and votes are closed.