generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: "Frame is not a valid member of ScreenGui"

Previous Thread :: Next Thread 
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 06:35 PM
Not sure what's going on here.

textButton.MouseButton1Down:connect(function()
if script.Parent.ScreenGui.Frame.Visible == false then
textButton.Text = "Hide"
for _,v in pairs(script.Parent.ScreenGui:GetChildren()) do
v.Visible = true
end
end
if script.Parent.ScreenGui.Frame.Visible == true then
textButton.Text = "Show"
for _,v in pairs(script.Parent.ScreenGui:GetChildren()) do
v.Visible = false
end
end
end)




My StarterGui is like this

StarterGui
LocalScript
ScreenGui
Frame

Anyone know what's going on?
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 06:35 PM
Ugh.

StargetGui
-----LocalScript
-----ScreenGui
----------Frame
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 06:36 PM
*Starter. So much fail.
Report Abuse
Everment is not online. Everment
Joined: 08 Oct 2009
Total Posts: 6020
28 Jan 2015 06:36 PM
Best guess is that the frame doesn't exist yet so try using the WaitForChild method.

It should be loaded by the time someone can click on a button, but it's always worth the try.
Report Abuse
iGotRekt is not online. iGotRekt
Joined: 23 Jan 2014
Total Posts: 831
28 Jan 2015 06:40 PM
local frame = script.Parent.ScreenGUI:WaitForChild("Frame")

textButton.MouseButton1Down:connect(function()
if frame.Visible == false then
textButton.Text = "Hide"
for _,v in pairs(script.Parent.ScreenGui:GetChildren()) do
v.Visible = true
end
end
if frame.Visible == true then
textButton.Text = "Show"
for _,v in pairs(script.Parent.ScreenGui:GetChildren()) do
v.Visible = false
end
end
end)

Like this, Ever?

✗ вυяиσυт699 » ɪGᴏᴛRᴇᴋᴛ
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 06:42 PM
Hm... Then the GUI doesn't load at all. Something is very wrong.
Report Abuse
Everment is not online. Everment
Joined: 08 Oct 2009
Total Posts: 6020
28 Jan 2015 06:42 PM
I just noticed that you have two if statements. That means that when the first if statement is done, the second is also checked for. Since, in the first, you set the visibillity to true, then once you get to the second if statement you check for it to be true. This will always be the case practically.

Easy fix: turn "end if" to "elseif"

Other than the fact that you used "ScreenGUI" instead of "ScreenGui" (and obviously what I just pointed out) it looks fine.
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 06:45 PM
Nope, apparently line 12 (if script.Parent.ScreenGui.Frame.Visible == false then) is wrong. WAHHHHT.
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 06:53 PM
Alrighty, after attempting a number of things, including deleting and remaking "ScreenGui" and "Frame" I still get an error. Not sure why this is happening.
Report Abuse
Everment is not online. Everment
Joined: 08 Oct 2009
Total Posts: 6020
28 Jan 2015 06:54 PM
`if script.Parent.ScreenGui.Frame.Visible == false then` isn't throwing an error for me. Must be one of the lines before you connect to MouseButton1Down.
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 06:55 PM
Here it be.

local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent

local textButton = Instance.new("TextButton")
textButton.Parent = screenGui
textButton.Position = UDim2.new(0, 0, 0, 0)
textButton.Size = UDim2.new(0, 50, 0, 10)
textButton.BackgroundColor3 = BrickColor.White().Color
textButton.Text = "Show"
Report Abuse
freerobux456 is not online. freerobux456
Joined: 25 Feb 2010
Total Posts: 244
28 Jan 2015 06:56 PM
try jsut using click instead of down xD
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 06:56 PM
Is it possible, at all, that it could have been messed up during a transfer? I was working on my game, I ran a bad script and had to restart, so I saved what I could, including "ScreenGui" and all its children (frame and three buttons).

LocalScript Is the same.
Report Abuse
Everment is not online. Everment
Joined: 08 Oct 2009
Total Posts: 6020
28 Jan 2015 06:57 PM
Yeah, that's kinda relevant.

The problem is the script doesn't know which ScreenGui you're talking about, since you have the one that's premade and the one you instance. The script is always going for the one that was instanced, and that means since there's no frame, it can't find anything.

The way to fix this problem is to actually name your ScreenGuis and such.
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 07:00 PM
Okay so I re-copied the script, and the frame appears. Yay!

But the buttons don't appear. Problem?
Report Abuse
CaptainRexA is not online. CaptainRexA
Joined: 01 Jun 2010
Total Posts: 210
28 Jan 2015 07:13 PM
I fixed it.

Renamed everything, made local screengui = ButtonGUI etc.

Thanks to everyone who helped!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image