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

Table Expected, got nil????????????

local mod = require(game.ReplicatedStorage:WaitForChild("ModuleScript"))
local equipped
for i, v in pairs(mod) do -- This line errors
	if v.Equipped == true then
		equipped = v
	end
end

So I am trying to loop through a module script. That was my script in workspace above. Here is my module script:

return {
	
	["Really blue"] = {Equipped = true; Owned = true; Cost = 0};
	["Really red"] = {Equipped = false; Owned = false; Cost = 25}
	
}

2 comments

1

Is your ModuleScript directly under ReplicatedStorage and named "ModuleScript"?

0

@ankurbohra, yes.

1 answer

In your ModuleScript, try replacing all ;s with ,s and/or instead of ["Really blue"] and ["Really red"] do Really blue and Really red.

Like this:

return {

    Really blue = {Equipped = true, Owned = true, Cost = 0},
    Really red = {Equipped = false, Owned = false, Cost = 25}

}

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