Hi, I'm creating a simple developer product store, and I have set a dictionary to set each button automatically.
For some reason, every time I run this script, every single button gets put as the first index in the dictionary, it doesn't run through all of them.
--// Services
local pls = game:GetService("Players")
--// References
local plr = pls.LocalPlayer
local mainFolder = script.Parent
local marketMain = mainFolder.Main
local sideMain = mainFolder.SideMain
-- Side
local sideBox = sideMain.SideBox
local sideTitle = sideMain.SideTitle.SideBox.Title
local sidebuyButton = sideBox.Buy.MainButton
local sideItemPicture = sideBox.Item
local sideDescription = sideBox.Description
local selected = sideBox.Selected
-- Main
local main = marketMain.Top
local items = main.Items
--// Variables
local devProductIds = {375124828, 375124944, 375125031, 375125132, 375125253}
local devProductInfo = { --Title, Description, Price, Texture
[375124828] = {"+2,500 Steps", "Purchasing this will grant you a one time +2,500 steps.", 15, 2337297081};
[375124944] = {"+5,000 Steps", "Purchasing this will grant you a one time +5,000 steps.", 25, 2337297230};
[375125031] = {"+10,000 Steps", "Purchasing this will grant you a one time +10,000 steps.", 40, 2337297386};
[375125132] = {"+22,500 Steps", "Purchasing this will grant you a one time +22,500 steps.", 55, 2337297531};
[375125253] = {"+30,000 Steps", "Purchasing this will grant you a one time +30,000 steps.", 75, 2337297727};
};
for i = 1,#devProductIds do
for _,v in pairs(items:GetChildren()) do
if v.Name == "Item" then
v.Name = devProductInfo[devProductIds[i]][1]
local button = v.Button
button.Image = "rbxassetid://"..devProductInfo[devProductIds[i]][4]
button.Activated:connect(function()
sideItemPicture.pic.Image = "rbxassetid://"..devProductInfo[devProductIds[i]][4]
sideTitle.Text = devProductInfo[devProductIds[i]][1]
sideDescription.Text = devProductInfo[devProductIds[i]][2]
sideBox.Price.Text = "R$"..devProductInfo[devProductIds[i]][3]
selected.Value = devProductIds[i]
end)
end
end
end

2 comments
i think it's because dictionaries don't use index or something idk, try to use an array.
you're right. They dont. They also don't have an order, which is why dictionaries can at times print the wrong order.