So I have an instructions GUI with lots of buttons and frames, and the script that makes the frames open and close is extremely inefficient. I have to manually add each frame every time a add a new button to the GUI, and its super time consuming. What I would like to know is if there is a function that can get all the children of a frame except one specific one. Is that possible?
local BUTTON = script.Parent local TlFRAME = BUTTON.Parent.Parent local FRAME = TlFRAME.Arbalest local NAME = BUTTON.Text local ITEMNAME = FRAME.Itemname local CRUDECLUB = TlFRAME.CrudeClub local HUNTINGCLUB = TlFRAME.HuntingClub local FLINT = TlFRAME.Flint local CRUDEBUCKET = TlFRAME.CrudeBucket local COPPERAXE = TlFRAME.CopperAxe local COPPERPICKAXE = TlFRAME.CopperPickaxe local IRONAXE = TlFRAME.IronAxe local IRONPICKAXE = TlFRAME.IronPickaxe local CRUDEBOW = TlFRAME.CrudeBow local CRUDEFISHINGROD = TlFRAME.CrudeFishingRod local LONGBOW = TlFRAME.Longbow local SHORTBOW = TlFRAME.Shortbow local HUNTINGBOW = TlFRAME.HuntingBow local FISHINGROD = TlFRAME.FishingRod local CROSSBOW = TlFRAME.Crossbow local ARBALEST = TlFRAME.Arbalest local STEELAXE = TlFRAME.SteelAxe local STEELPICKAXE = TlFRAME.SteelPickaxe local BUCKET = TlFRAME.Bucket local CRAFTINGKNIFE = TlFRAME.CraftingKnife local SKINNINGKNIFE = TlFRAME.SkinningKnife local LUMBERSAW = TlFRAME.Lumbersaw local SLEDGEHAMMER = TlFRAME.SledgeHammer local MASONRYHAMMER = TlFRAME.MasonryHammer local BLUNDERBUSS = TlFRAME.Blunderbuss local FLINTSTEEL = TlFRAME.FlintSteel local DYE = TlFRAME.Dye FRAME.Visible = false function on_button1_down() CRUDECLUB.Visible = false HUNTINGCLUB.Visible = false FLINT.Visible = false CRUDEBUCKET.Visible = false COPPERAXE.Visible = false COPPERPICKAXE.Visible = false IRONAXE.Visible = false IRONPICKAXE.Visible = false CRUDEBOW.Visible = false CRUDEFISHINGROD.Visible = false LONGBOW.Visible = false SHORTBOW.Visible = false HUNTINGBOW.Visible = false FISHINGROD.Visible = false CROSSBOW.Visible = false --ARBALEST.Visible = false STEELAXE.Visible = false STEELPICKAXE.Visible = false BUCKET.Visible = false CRAFTINGKNIFE.Visible = false SKINNINGKNIFE.Visible = false LUMBERSAW.Visible = false SLEDGEHAMMER.Visible = false MASONRYHAMMER.Visible = false BLUNDERBUSS.Visible = false FLINTSTEEL.Visible = false DYE.Visible = false ITEMNAME.Text = NAME FRAME.Visible = (not FRAME.Visible) end BUTTON.MouseButton1Down:connect(on_button1_down)
Sorry retread question I would still suggest using a for loop but with a conditional statement
For I,v in pairs (Frame:Getchilrden()) do If v.Name ~= -- item to avoid V.visible = false end end
local BUTTON = script.Parent local ITFRAME = BUTTON.Parent.Parent local FRAME = ITFRAME.Hull local NAME = BUTTON.Text local ITEMNAME = FRAME.Itemname local SCROLLINGFRAME = ITFRAME.ScrollingFrame FRAME.Visible = false function on_button1_down() for I,v in pairs (FRAME:Getchilrden()) do if v.Name ~= SCROLLINGFRAME-- item to avoid then v.Visible = false else I.Visible = true end ITEMNAME.Text = NAME FRAME.Visible = (not FRAME.Visible) end end BUTTON.MouseButton1Down:connect(on_button1_down)
So would this work?
That's a pretty simple problem and can easily be solved with a for _, fr in pairs(TlFrame:GetChildren()) do which will do the stuff inside of this and an end to anything inside of this table.
local BUTTON = script.Parent local TlFRAME = BUTTON.Parent.Parent local FRAME = TlFRAME.Arbalest local NAME = BUTTON.Text local ITEMNAME = FRAME.Itemname FRAME.Visible = false function on_button1_down() for _, fr in pairs(TlFrame:GetChildren()) do if fr ~= FRAME then -- This will prevent the content of the FRAME variable from being changed. fr.Visible = false end end ITEMNAME.Text = NAME FRAME.Visible = (not FRAME.Visible) end BUTTON.MouseButton1Down:connect(on_button1_down)
If this doesn't help you with your problems or isn't what you needed, simply reply in a comment and I'll see what I can do.