So I've been making an inventory for my fishing game, I have created RemoteEvent that will fire whenever player gets new item to his inventory. I did "GUI" inventory with bunch of slots instead of making individual tables for each player. And now I'm stuck at making inventory saving system, I hope someone helps me :)
There's code:
local slots = script.Parent.Inventory.Slots
local run_service = game:GetService("RunService")
local function init()
for i,v in pairs(slots:GetChildren()) do
if v.Name == 'Slot' then
if v.Item.Value == '' and v.Amount.Value == 0 then
v.Visible = false
else
v.Visible = true
v.ItemLabel.Text = v.Item.Value
v.AmountLabel.Text = tostring(v.Amount.Value)
v.RarityLabel.Text = v.Rarity.Value
end
end
end
end
local function got_item(item)
for i,v in pairs(slots:GetChildren()) do
if v.Name == 'Slot' then
if v.Item.Value == '' and v.Amount.Value == 0 then
v.Item.Value = item
v.Amount.Value = 1
v.Rarity.Value = 'Unspecified'
break
elseif v.Item.Value == item and v.Amount.Value > 0 then
v.Amount.Value = v.Amount.Value + 1
break
end
end
end
end
run_service.RenderStepped:connect(init)

2 comments
Thank you for your answer, I know exactly how data stores work, but I don't know how to save each of the slot, I must make for i,v loop or something, any ideas?
Oh nevermind I figured it out how to do it, thanks for your answer again