I’m making a shop system for my game where each tool will cost different ingredients in different quantities, I have stored all of these in a Module Script just as shown in the example below :
Now, to show each ingredient required, I’m trying to get the variables inside “Fork” such as “Raspberry” and the amount needed, but I am not acquainted with Module Scripts so I’m not sure how I would gather the variables & their values like a :GetChildren() loop but for variables.
Doing it manually was proven to be very unefficient as there are over 10 ingredients so far with more to come in the future and some tools don’t require all of the ingredients.
This might be an easy fix but I just can’t think of anything right now!
Not sure if I’m not doing it right or something but it just returns an error : “invalid argument #1 to ‘pairs’ (table expected, got nil)”
local array = table.unpack(weaponModule[class])
print(array)
The print is just there to check but it returns nil, I’m sure weaponModule[class] works because I’m using it for the description of the item and it works just fine.
I did require yes. Here’s a bit more data you might need
local weaponModule = require(game.ReplicatedStorage:WaitForChild("ShopEvents"):WaitForChild("ShopWeapons"))
script.Parent.MainFrame.RightArrow.MouseButton1Click:Connect(function()
for i,v in pairs(camobj:GetChildren()) do --Stuff done above the code, works fine
if v.Name == "Class" then
local class = v.Value
script.Parent.MainFrame.Cost.ObjectName.Text = class --Actually says the correct name of the class
script.Parent.MainFrame.Cost.Description.Text = weaponModule[class].Description --Works perfectly fine
local array = table.unpack(weaponModule[class])
print(array) --Returns nil
end
end
end)