I have a (Dictionary) like this (Basically this module is for the lucky box)
local Inventory = { ["Starter"] = { ["Cost"] = 200, ["Sword"] = { ["Ice"] = {"Ice", 35}, --35 is the rarity ["Fire"] = {"Fire", 35}, ["Water"] = {"Water", 20}, ["Soil"] = {"Soil", 10}, } } } return Inventory
and i want to make a Image GUI for the ice,fire,water, and soil but why this script only Clone 1 Image Template instead of 4???
local ShopData = require(script.ModuleScript) template.MouseButton1Click:Connect(function() for i,v in pairs(ShopData["Starter"]["Sword"]) do local CloneTemp = script.Template:Clone() CloneTemp.Parent = script.Parent.ScrollingFrame CloneTemp.Name = v[1] CloneTemp.SwordName.Text = v[1] CloneTemp.Percent.Text = v[2] .."%" end end)
EDIT: this script works fine guys, my mistakes i forgot that i add this after the for i,v instead of after click
for a,x in pairs (Detail.Info.List:GetChildren()) do --Clear the previous layout if x.Name ~= "UIGridLayout" then x:Destroy() x = nil end end
You made a dictionary, not a table, so you would need to use i as well.
local ShopData = require(script.ModuleScript) template.MouseButton1Click:Connect(function() for i,v in pairs(ShopData["Starter"]["Sword"]) do local CloneTemp = script.Template:Clone() CloneTemp.Parent = script.Parent.ScrollingFrame CloneTemp.Name = i CloneTemp.PetName.Text = v[1] CloneTemp.Percent.Text = v[2] end end)
I just changed the v to i.