So this is a GUI script that should open and close the frame named FRAME when clicked, but it also needs to always have a frame called ScrollingFrame visible. This script seems like when clicked it doesn't recognize ScrollingFrame as a child so it just makes all of the frames Visibility false. To sum up the objective of the script it is to toggle "FRAME"'s visibility when the button is clicked, but leave ScrollingFrame (one of the children of ITFRAME) visible at all times. thanks for any help guys!
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 | for I,v in pairs (ITFRAME:GetChildren()) do |
12 | if v.Name = = ScrollingFrame -- Most likely the problem, isn't recognizing the ScrollingFrame as a Child of ITFRAME? |
13 | then v.Visible = true |
14 | else v.Visible = false |
15 | end |
16 | end |
17 | ITEMNAME.Text = NAME |
18 | end |
19 | BUTTON.MouseButton 1 Down:connect(on_button 1 _down) |
Bare ScrollingFrame
is the variable ScrollingFrame
. Since you haven't set that, it's just another name for nil
, which is not the name of any object.
To make text, called strings, you need to enclose the words in quotes, either double or single:
1 | if v.Name = = "ScrollingFrame" then |
'Not recognizing' almost never happens--it's essentially always because you're forgetting something.
Thanks BlueTaslem, that worked, but now what it does is makes the frame appear like it should, but I don't know how to tell it to make the frame not visible again. The way I was doing it before was the FRAME.Visible = (not FRAME.Visible) line but that doesn't seem to be working anymore.
01 | local BUTTON = script.Parent |
02 | local ITFRAME = BUTTON.Parent.Parent |
03 | local FRAME = ITFRAME.SmallHandle |
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 | for I,v in pairs (ITFRAME:GetChildren()) do |
12 | if v.Name = = "ScrollingFrame" |
13 | --or v.Name == "Hull" -- not sure if I should put this in here or not |
14 | then v.Visible = true |
15 | else v.Visible = false |