|
| 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 |
|
|
|
| 28 Jan 2015 06:35 PM |
Ugh.
StargetGui -----LocalScript -----ScreenGui ----------Frame |
|
|
| Report Abuse |
|
|
| |
|
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
|
  |
| 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 |
|
|
|
| 28 Jan 2015 06:42 PM |
| Hm... Then the GUI doesn't load at all. Something is very wrong. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 28 Jan 2015 06:45 PM |
| Nope, apparently line 12 (if script.Parent.ScreenGui.Frame.Visible == false then) is wrong. WAHHHHT. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 28 Jan 2015 06:56 PM |
| try jsut using click instead of down xD |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 28 Jan 2015 07:13 PM |
I fixed it.
Renamed everything, made local screengui = ButtonGUI etc.
Thanks to everyone who helped! |
|
|
| Report Abuse |
|
|