Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a ui button for every item in backpack?

Asked by 2 years ago
Edited 2 years ago

im trying to make an inventory system and im trying to make it so: if a player owns a tool it will be in the backpack if its in the backpack the button with the same name will be visible

the problem: on child added doesnt work

this is what i have so far:

local script inside StarterGui.Inventory.MainFrame.Menu.ScrollingFrame

local player = game.Players.LocalPlayer
local backpack = player.Backpack

function togglebutton(name)
    local ui = script.Parent
    for i,v in pairs(ui:GetChildren()) do
        if v.Name == name then
            v.Visible = true
        end
    end
end

function dostuff()
    for i,v in pairs(player.Backpack:GetChildren()) do
        if v:IsA("Tool") then
            togglebutton(v.Name) 
        end
    end
end 

game.Players.PlayerAdded:Connect(dostuff)
backpack.ChildAdded:Connect(dostuff)

0
Fixed most of it. just need to find out why child added doesnt work MightBeAHaxxer 24 — 2y
0
Solved. please dont help. its useless now! MightBeAHaxxer 24 — 2y

Answer this question