Hi!
-
What do you want to achieve? I want to make a Backpack Gui which looks like 2008-2009 Roblox.
-
What is the issue? When using the buttons, it changes up the order of the stuff, which is not what I want.
-
What solutions have you tried so far? I tried making it automatically set the order in ReplicatedStorage.
Here’s the script which clones each icon into the backpack.
--This script allows the hotbar to show all tools in the backpack, and remove them when needed.
local template = game:GetService("ReplicatedStorage"):WaitForChild("IconTemplate")
local bp = script.Parent.Parent.Parent.Parent.Backpack
function checkBackPack()
-- Remove all existing tools in the bp
local insval = 0
for i,z in pairs(script.Parent:GetChildren()) do
if z:IsA("Frame") and z.EquippedV.Value ~= true then
z:Destroy()
end
end
-- Loop through all tools in the bp
for i,e in pairs(bp:GetChildren()) do
if not script.Parent:FindFirstChild(e.Name) then
local c = template:Clone()
c.Parent = script.Parent
c.Name = e.Name
c.NameLabel.Text = e.Name
insval += 1
if not game.ReplicatedStorage.ItemOrderNums:FindFirstChild(bp.Parent.Name) then
local folder = Instance.new("Folder")
folder.Name = bp.Parent.Name
folder.Parent = game.ReplicatedStorage.ItemOrderNums
end
if not game.ReplicatedStorage.ItemOrderNums[bp.Parent.Name]:FindFirstChild(c.Name) then
local v = Instance.new("NumberValue")
v.Name = c.Name
v.Parent = game.ReplicatedStorage.ItemOrderNums[bp.Parent.Name]
c.Order.Value = insval
c.Number.Text = tostring(insval)
v.Value = c.Order.Value
else
c.Order.Value = game.ReplicatedStorage.ItemOrderNums[bp.Parent.Name][c.Name].Value
c.Number.Text = tostring(game.ReplicatedStorage.ItemOrderNums[bp.Parent.Name][c.Name].Value)
end
--[[if e.TextureId ~= nil then
c.Icon.ToolTXT.Visible = false
c.Icon.ToolIMG.Visible = true
c.Icon.ToolIMG.Image = e.TextureId
end]]
end
end
end
-- Run when someone joins
bp.ChildAdded:Connect(checkBackPack)
-- Run when someone leaves
bp.ChildRemoved:Connect(checkBackPack)
-- Run on initialize
checkBackPack()
Here is some explorer structure (BackpackNumberSelection is not part of this issue right now):
Video of the bug occurring:
Thanks!