So currently I have a custom backpack however I'm unsure how I could change the order of the layout of weapons. I'd like to have the ranged weapons (ie guns, bows) in slot 1 and melee weapons (ie swords, bats) in slot 2. For Example, If I had a sword named "AzureSword" and a gun named "Pistol" then the sword will be in slot 1 and the pistol will be in slot 2, based off of alphabetical order. I'm not sure how I could get around this without renaming the weapons. Does anyone have any ideas?
Not sure if this is useful but, custom backpack script:
local Items = {}
local frames = {}
local Equiped = nil
local Player = game.Players.LocalPlayer
local Character = Player.Character
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
function Scan(location)
for i,v in pairs(location:GetChildren()) do
if v:IsA("Tool") then
table.insert(Items,v)
end
end
end
function Update()
print(Equiped)
for i,v in pairs(frames) do
v:Destroy()
end
for i,v in pairs(Items) do
local sam = script.Sample:Clone()
sam.Name = v.Name
sam.Parent = script.Parent.Holder
sam.ImageLabel.Image = v.TextureId
sam.Text = v.Name
table.insert(frames,sam)
if Equiped ~= nil and Equiped == v then
sam.BorderSizePixel = 2
end
sam.MouseButton1Click:connect(function()
if Equiped == nil or Equiped ~= v then
Equiped = v
Character.Humanoid:UnequipTools()
Character.Humanoid:EquipTool(v)
else
Equiped = nil
Character.Humanoid:UnequipTools()
end
end)
end
end
function backpackchanged()
Items = {}
Scan(Character)
Scan(Player.Backpack)
Update()
end
backpackchanged()
Player.Backpack.ChildAdded:connect(backpackchanged)
Player.Backpack.ChildRemoved:connect(backpackchanged)
Character.ChildAdded:connect(backpackchanged)
Character.ChildRemoved:connect(backpackchanged)
