I want to limit my game to only one backpack slot.
The idea is that if a player is holding an item and wants to pick a different one up, the previous one would drop on the ground. The second one would be the one picked up.
The problem is that when the items get swapped, the one dropped on the ground can no longer be picked up anymore. Other than that, it's getting placed in the second slot instead of the first one.
The script I used:
local limit = 1 function updateTools() local backpack = game.Players.LocalPlayer:WaitForChild("Backpack") local char = script.Parent local tools = {} for i, child in pairs(char:GetChildren()) do if child:IsA("Tool") then table.insert(tools, child) end end for i, tool in pairs(backpack:GetChildren()) do table.insert(tools, tool) end for i, tool in pairs(tools) do if i > limit then tool.Parent=workspace end end end local backpack = game.Players.LocalPlayer:WaitForChild("Backpack") backpack.DescendantAdded:Connect(updateTools) backpack.DescendantRemoving:Connect(updateTools) workspace.DescendantAdded:Connect(updateTools) workspace.DescendantRemoving:Connect(updateTools)