Hello, im just making a game with alot of IDs for different stuff in shop so i used module script to put all the data from the shop there. Actually i gonna send only one thing from the script because if i send the whole script it will be a spam and also its pointless because everything else is same as this just different values on it. So this is my module script
local info = {} Chars = { ["Robot1"] = { Name = "Robot", Price = 0, Health = 100, Head = 0, Torso = 54116290, RightArm = 54116338, RightLeg = 54116432, LeftArm = 54116373, LeftLeg = 54116394, }, } return info
Im trying to use some of the values there into my actual codes but the output says that table "Chars" is a nil value. I tried a few different ways to do it but it still does not work do you know why? Here is what i tried. I will put just a simple prints and the errors
local info = require(game.ServerStorage:WaitForChild("Modules").Info) print(info:GetChars()[1][1]) -- attempt to call method "GetChars"(a nil value) print(info.Chars[1][1]) -- attempt to index field "Chars" (a nil value) print(info.Chars["Robot1"]["Name"]) -- attempt to index field "Chars" (a nil value)
Anyone know why?
It's pretty simple.
Look at line 1 for me.
local info = {}
info
points to an empty table.
You meant for Chars
to be a field in info
.
This works:
local info = { Chars = { Robot1 = { Name = "Robot", Price = 0, Health = 100, Head = 0, Torso = 54116290, RightArm = 54116338, RightLeg = 54116432, LeftArm = 54116373, LeftLeg = 54116394 } } } return info