I am currently producing a crafting system which uses the following array to get the ingredients and then the amount of that ingredient from a dictionary.
The “” Are blank and are recognised in code to be empty since this variable only uses 1 log to craft.
Here is where the error is coming up,
function CheckCraft()
for i,v in next, script.Parent.ScrollingFrame:GetChildren() do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
Ingredient = script.Parent.IngredientTemplate
Ingredient.Line1.Text = Resources[v.Name[1]].." x "..Resources[v.Name[4]]
function CheckCraft()
for i,v in next, script.Parent.ScrollingFrame:GetChildren() do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
Ingredient = script.Parent.IngredientTemplate
Ingredient.Line1.Text = Resources[v.Name][1].." x "..Resources[v.Name][4]
v.Name is a string and trying to make a string behave like a table, (v.Name[1]), returns nil.
I think its down to the [1] part not being able to be used in dictionaries, testing before it works using code like this
local AmountRequired = 1
function CheckCraft()
for i,v in next, script.Parent.ScrollingFrame:GetChildren() do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
Ingredient = script.Parent.IngredientTemplate
Ingredient.Line1.Text = Resources[v.Name].." x "..AmountRequired
local Resources = {
["WoodPlanks"] = {"Logs", "", "", 1, "",""},
}
for _ , resourcetype in pairs(Resources) do
for i = 1,#resourcetype do
print(resourcetype[i])
end
end
There error looks like it’s finding your string data, but not Ingredient.Line1.Text