Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I pull value from table?

Asked by 3 years ago

I got a inventory system when you click a part it gets listed in the table and saved in there. I want to make a shop where you click a GUI button and it gets the price value for each Item in the table and give you money. Then clears the Table.

I'm added the sell system to this https://devforum.roblox.com/t/open-sourced-inventory-system/911931/43

Main script when GUI button is clicked it fires this


RepStorage.Remotes.Sell.OnServerEvent:Connect(function(player, item) local itemInfo = ItemsInfo[item] local Sum = itemInfo.Price Sum = 0 for i,v in pairs(itemInfo) do Sum = Sum + v end if Sum > 0 then local player = game.Players.LocalPlayer player.leaderstats.Teccers.Value = player.leaderstats.Teccers.Value + Sum end end)

The items values are in this table in a different script

local ItemModels = script.Parent.ItemModels

local ItemsInfo = {


    ["Stone"] = {
        Name = "Stone";
        Price = 5;
    };
    ["Gold"] = {
        Name = "Gold";
        Price = 500;    
    };  
}

return ItemsInfo

Answer this question