ssurakkuu
(ssurakkuu)
August 5, 2023, 9:18pm
#1
Hello, I am trying to have the following code get the “TierNumber” from my module script, as below
The issue with this above is if I change
local TierNumber = ItemDataModule[CurrentWorkbench].Resources.Tier
to
local TierNumber = ItemDataModule[CurrentWorkbench][Category].Tier
It says this is index nil with Tier, even though the script is printing Category as “Resources”
Any ideas would be appreciated.
I can also provide more information if needed
1 Like
MichaveIi
(Michaveli)
August 5, 2023, 9:27pm
#2
can u print
print(Category)
print(type(Category))
print(CurrentWorkbench)
print(unpack(ItemDataModule[CurrentWorkbench]))
xpcall(function()
print(unpack(ItemDataModule[CurrentWorkbench][Category]))
end, function() warn("wrong") end)
and send me the console
1 Like
ssurakkuu
(ssurakkuu)
August 5, 2023, 9:33pm
#4
The itemdata for the category and workbench itself both resulted in nothing in the console
Below is the workbench data
1 Like
MichaveIi
(Michaveli)
August 5, 2023, 9:37pm
#5
it’s because
ItemDataModule[CurrentWorkbench]
is empty as shown by the result of the unpack
1 Like
ssurakkuu
(ssurakkuu)
August 5, 2023, 9:47pm
#6
Well even when doing this
print(unpack(ItemDataModule["Workbench Tier 1"]))
It still doesn’t get any data even though the image in my previous reply shows there is indeed data in that table
1 Like
ssurakkuu
(ssurakkuu)
August 5, 2023, 9:59pm
#8
After doing this, ive tried doing this at the beginning of the script where its being defined
local ItemDataModule = require(game.ReplicatedStorage.GameSettings.ItemData)
print(unpack(ItemDataModule))
Even here it doesn’t even recognize the module
Not sure if this is a me issue or a studio issue at this point
1 Like
MichaveIi
(Michaveli)
August 5, 2023, 10:01pm
#9
does itemdatamodule exist in that variable?
try writing it like this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GameSettings = ReplicatedStorage:WaitForChild("GameSettings")
local ItemDataModule = GameSettings:WaitForChild("ItemData")
local ItemData = require(ItemDataModule)
print(unpack(ItemDataModule))
2 Likes
ssurakkuu
(ssurakkuu)
August 5, 2023, 10:08pm
#10
thank ya, I don’t know how that never crossed my mind but thanks a lot.
1 Like
system
(system)
Closed
August 19, 2023, 10:08pm
#11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.