Hello, can anyone help me?
Is it possible to reduce the table number later in the same script? I need to reduce
Count
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local backpack = player.Backpack
local char = player.Character or player.CharacterAdded:Wait()
local function ScanItems()
local items = {}
--Scanning Backpack
for i, tool in pairs(backpack:GetChildren()) do
if tool.ClassName == "Tool" then
table.insert(items, tool)
end
end
--Scanning Character
for i, tool in pairs(char:GetChildren()) do
if tool.ClassName == "Tool" then
table.insert(items, tool)
end
end
--Creating New List
local invItems = {}
for i, tool in pairs(items) do
if invItems[tool.Name] then
invItems[tool.Name].Count += 1
table.insert(invItems[tool.Name].Items, tool)
else
invItems[tool.Name] =
{Count = 1;
Items = {tool};
}
end
end
return invItems
end