Alright, I’m trying to set a value by looping through a dictionary but it only sets the value to one of the values in the dictionary
Here is the code if you want to see it
local tools = game.ReplicatedStorage.Tools:GetChildren()
local zPos = 0.5
local items = {
Uzi = 100,
Rifle = 500
}
for i=1,#tools do
-- { Part
zPos = zPos + studgap
print("new part")
local shop_part = Instance.new("Part",workspace)
shop_part.Anchored = true
shop_part.CFrame = CFrame.new(-0.5, 0.6, zPos)
-- }
-- { Values
local tool = Instance.new("StringValue")
tool.Parent = shop_part
local cost = Instance.new("NumberValue")
cost.Parent = shop_part
cost.Name = "Price"
for key, value in pairs (items) do
shop_part:FindFirstChild("Price").Value = value
end
--}
--{ Click detector
local cd = Instance.new("ClickDetector",shop_part)
--}
--{ Buy
cd.MouseClick:Connect(function(plr)
local leaderstats = plr:FindFirstChild("leaderstats")
local gold = leaderstats:FindFirstChild("Gold")
if gold.Value >= shop_part.Price.Value then
print("Clicked!")
end
end)
--}
end