I am making an inventory system and I was wondering how I'd make it automated? Here is what I mean: The slots will automatically be filled when an item is added, if there is already an item it moves to the next slot. If there is no slot, it creates a new one. This is the code I have right now for the frame, I had something else but it was very inefficient. Right now all I have is printing what items the player has. If anyone could either help with the script, point me in a good direction, or tell me what I should learn It'd be very appreciated.
local player = game.Players.LocalPlayer local b = player.Backpack local gui = script.Parent local spots = gui:FindFirstChild("Open1") -- Open Slot local spot2 = gui:FindFirstChild("Open2") -- Open Slot local event = game.ReplicatedStorage.InventoryAdd -- Remote event local salad = game.ReplicatedStorage.f -- Just a remote event for client event local fol = script.Parent -- The folder where the Slot frames and this script event:FireServer() -- this just checks if player has an item and changes the value of the item to true local pizza = player:WaitForChild("PStats"):WaitForChild("Items"):GetChildren() for i = 1, #pizza do print(i, pizza[i].Name) end local function ItemCheck() -- Code to go here to update GUI end salad.OnClientEvent:connect(ItemCheck)