Server-side inventory using a table. Add, remove, and check items.
-- Inventory System local ReplicatedStorage = game:GetService("ReplicatedStorage") local inventories = {} local getInvRF = Instance.new("RemoteFunction") getInvRF.Name = "GetInventory"; getInvRF.Parent = ReplicatedStorage game.Players.PlayerAdded:Connect(function(p) inventories[p.UserId] = {} end) game.Players.PlayerRemoving:Connect(function(p) inventories[p.UserId] = nil end) local function addItem(player, itemId, qty) local inv = inventories[player.UserId]; if not inv then return end inv[itemId] = (inv[itemId] or 0) + (qty or 1) end local function removeItem(player, itemId, qty) local inv = inventories[player.UserId]; if not inv or not inv[itemId] then return false end qty = qty or 1; if inv[itemId] < qty then return false end inv[itemId] = inv[itemId] - qty if inv[itemId] <= 0 then inv[itemId] = nil end return true end getInvRF.OnServerInvoke = function(player) return inventories[player.UserId] or {} end