I have a inventory system which has a gui, so when you kill a item it goes into a table and is displayed on the gui.
I want to Make a shop in which will sell all items in the players inventory folder and then clear it.
Here is the shop gui script
script.Parent.MouseButton1Click:Connect(function() local ReplicatedStorage = game:GetService("ReplicatedStorage") ReplicatedStorage.Remotes.Sell:FireServer() end)
Here is the what gets loaded on to the table when there needed.
local ItemsInfo = { ["item1"] = { Price = 200; }; ["item2"] = { Price = 10; }; return ItemsInfo
Table is in sever scrips
local Inventory = { }
Here is the main problem
RepStorage.Remotes.Sell.OnServerEvent:Connect(function(item, player) 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)
Please try and help, Or at least give something
The problem is on the first line.
When doing .OnServerEvent, the first parameter is always going to be player
.
So, switch the parameters around by doing (player, item)