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?
01 | local BUTTON = script.Parent |
02 | local TlFRAME = BUTTON.Parent.Parent |
03 | local FRAME = TlFRAME.Arbalest |
04 | local NAME = BUTTON.Text |
05 | local ITEMNAME = FRAME.Itemname |
06 |
07 | local CRUDECLUB = TlFRAME.CrudeClub |
08 | local HUNTINGCLUB = TlFRAME.HuntingClub |
09 | local FLINT = TlFRAME.Flint |
10 | local CRUDEBUCKET = TlFRAME.CrudeBucket |
11 | local COPPERAXE = TlFRAME.CopperAxe |
12 | local COPPERPICKAXE = TlFRAME.CopperPickaxe |
13 | local IRONAXE = TlFRAME.IronAxe |
14 | local IRONPICKAXE = TlFRAME.IronPickaxe |
15 | local CRUDEBOW = TlFRAME.CrudeBow |
Sorry retread question I would still suggest using a for loop but with a conditional statement
1 | For I,v in pairs (Frame:Getchilrden()) do |
2 | If v.Name ~ = -- item to avoid |
3 | V.visible = false |
4 | end |
5 | end |
01 | local BUTTON = script.Parent |
02 | local ITFRAME = BUTTON.Parent.Parent |
03 | local FRAME = ITFRAME.Hull |
04 | local NAME = BUTTON.Text |
05 | local ITEMNAME = FRAME.Itemname |
06 | local SCROLLINGFRAME = ITFRAME.ScrollingFrame |
07 |
08 | FRAME.Visible = false |
09 |
10 | function on_button 1 _down() |
11 |
12 | for I,v in pairs (FRAME:Getchilrden()) do |
13 | if v.Name ~ = SCROLLINGFRAME -- item to avoid |
14 | then v.Visible = false |
15 | else I.Visible = true |
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.
01 | local BUTTON = script.Parent |
02 | local TlFRAME = BUTTON.Parent.Parent |
03 | local FRAME = TlFRAME.Arbalest |
04 | local NAME = BUTTON.Text |
05 | local ITEMNAME = FRAME.Itemname |
06 |
07 | FRAME.Visible = false |
08 |
09 | function on_button 1 _down() |
10 | for _, fr in pairs (TlFrame:GetChildren()) do |
11 | if fr ~ = FRAME then -- This will prevent the content of the FRAME variable from being changed. |
12 | fr.Visible = false |
13 | end |
14 | end |
15 | ITEMNAME.Text = NAME |
16 | FRAME.Visible = ( not FRAME.Visible) |
17 | end |
18 |
19 | BUTTON.MouseButton 1 Down:connect(on_button 1 _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.