Hi!
-
What do you want to achieve? I need my GUI which shows all items in the Backpack to the player (NOT interactable)
-
What is the issue? It thinks that the backpack is empty, causing it to not do anything useful.
-
What solutions have you tried so far? I’ve tried moving it to a LocalScript, and tried having the function run when the character loads (as seen in the script.
Here’s my script:
local player = game.Players.LocalPlayer
local bp = player.Backpack
function checkItems()
print("Checking Items")
--Remove all existing labels
for i,e in pairs(script.Parent:GetChildren()) do
if e:IsA("TextLabel") then
if e.SelectedBool == false then
print("Removing")
e:Destroy()
end
end
end
print("Passed removing area")
local selectionVal = 1
wait(0.1)
print(bp:GetChildren())
-- Create new labels
for i,e in pairs(bp:GetChildren()) do
print("Making new")
if not script.Parent:FindFirstChild(e.Name) then
print(e.Name.." is being made")
local label = game.ReplicatedStorage.Item:Clone()
label.Parent = script.Parent
label.Name = e.Name
label.Text = "["..tostring(selectionVal).."] "..e.ShowableName.Value
selectionVal += 1
end
end
print("Done")
end
player.CharacterAdded:Connect(checkItems)
bp.ChildAdded:Connect(checkItems)
bp.ChildRemoved:Connect(checkItems)
Explorer Structure:
Output:
Thanks!