The purpose of this script is to make the GUI (script.parent) invisible when the player has a tool in their starterpack. Can someone show me where I went wrong?
Thanks a million, Marcus
man = game.Players.LocalPlayer c = man.Backpack:GetChildren() function characterAdded () if 1==1 then for i = 1,#c do if c[i].className == "Tool" or c[i].className == "HopperBin" then local gog = game.StarterPack:findFirstChild(c[i].Name) if gog == nil then script.parent.Visible = false end end end end man.PlayerAdded:connect (characteradded)
You'll have to repeat c = man.Backpack:GetChildren()
every time you want the children, or else you always use the same table. You also might have to wait for the backpack to load. Here is your code with a few other other revisions.
player = game.Players.LocalPlayer --better name bp = player:WaitForChild('Backpack') c = bp:GetChildren() function characterAdded() --why check 1=1 ? c = bp:GetChildren() for _,v in pairs(c) do --using pairs may be better here if v:IsA("Tool") or v:IsA("HopperBin") then --:IsA is useful! local gog = game.StarterPack:FindFirstChild(v.Name) if not gog then script.parent.Visible = false end end end end player.CharacterAdded:connect(characterAdded) --the correct event