Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script possibly not recognizing Child?

Asked by 9 years ago

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!

01local BUTTON = script.Parent
02local ITFRAME = BUTTON.Parent.Parent
03local FRAME = ITFRAME.Hull
04local NAME = BUTTON.Text
05local ITEMNAME = FRAME.Itemname
06local ScrollingFrame = ITFRAME.ScrollingFrame
07 
08FRAME.Visible = false
09 
10function on_button1_down()
11   for I,v in pairs (ITFRAME:GetChildren()) do
12if v.Name == ScrollingFrame -- Most likely the problem, isn't recognizing the ScrollingFrame as a Child of ITFRAME?
13then v.Visible = true
14else v.Visible = false
15        end
16    end
17    ITEMNAME.Text = NAME
18end
19BUTTON.MouseButton1Down:connect(on_button1_down)

2 answers

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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:

1if v.Name == "ScrollingFrame" then

'Not recognizing' almost never happens--it's essentially always because you're forgetting something.

Ad
Log in to vote
0
Answered by 9 years ago

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.

01local BUTTON = script.Parent
02local ITFRAME = BUTTON.Parent.Parent
03local FRAME = ITFRAME.SmallHandle
04local NAME = BUTTON.Text
05local ITEMNAME = FRAME.Itemname
06local ScrollingFrame = ITFRAME.ScrollingFrame
07 
08FRAME.Visible = false
09 
10function on_button1_down()
11   for I,v in pairs (ITFRAME:GetChildren()) do
12if v.Name == "ScrollingFrame"
13--or v.Name == "Hull"  -- not sure if I should put this in here or not
14then v.Visible = true
15else v.Visible = false
View all 21 lines...

Answer this question