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)

2 comments

0

Fixed most of it. just need to find out why child added doesnt work

0

Solved. please dont help. its useless now!