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 8 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!


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 (ITFRAME:GetChildren()) do if v.Name == ScrollingFrame -- Most likely the problem, isn't recognizing the ScrollingFrame as a Child of ITFRAME? then v.Visible = true else v.Visible = false end end ITEMNAME.Text = NAME end BUTTON.MouseButton1Down:connect(on_button1_down)

2 answers

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 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:

if 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 8 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.

local BUTTON = script.Parent
local ITFRAME = BUTTON.Parent.Parent
local FRAME = ITFRAME.SmallHandle 
local NAME = BUTTON.Text
local ITEMNAME = FRAME.Itemname
local ScrollingFrame = ITFRAME.ScrollingFrame

FRAME.Visible = false

function on_button1_down()
   for I,v in pairs (ITFRAME:GetChildren()) do
if v.Name == "ScrollingFrame"
--or v.Name == "Hull"  -- not sure if I should put this in here or not
then v.Visible = true
else v.Visible = false
    FRAME.Visible = (not FRAME.Visible)
        end
    end
    ITEMNAME.Text = NAME
end
BUTTON.MouseButton1Down:connect(on_button1_down)

Answer this question