tyler09456
(RollMysts)
September 5, 2020, 5:18pm
#1
Hello! I’m trying to get this GUI to open/close when clicking a button and it just ain’t working what so ever.
local openbutton = game.StarterGui.ScreenGui.Settings.ImageButton
local Gui = game.StarterGui.ScreenGui.SettingsFrame
openbutton.MouseButton1Click:Connect(function()
Gui.Visible = true
if Gui.Visible == true then
Gui.Visible = false
end
end)
9 Likes
lexishh
(lexishh)
September 5, 2020, 5:20pm
#2
Could you show us your script and let us know if it’s a LocalScript or a ServerScript?
1 Like
tyler09456
(RollMysts)
September 5, 2020, 5:23pm
#3
It’s a local script and everything which is there has been put above.
1 Like
lexishh
(lexishh)
September 5, 2020, 5:25pm
#4
I see the problem, you shouldn’t be controlling the GUI from StarterGUI. Could I see the position of all the objects? Like
It needs to be a local script in the button: script.Parent.MouseButton1Click: Connect(function()
script.Parent.YourFrame.Visible = true
end)
3 Likes
You would need to be referring to playerGui the other way.
lexishh
(lexishh)
September 5, 2020, 5:27pm
#8
Replace your code with this
local openbutton = script.Parent
local Gui = script.Parent.Parent.Parent
openbutton.MouseButton1Click:Connect(function()
Gui.Enabled = true
if Gui.Enabled == true then
Gui.Enabled = false
end
end)
2 Likes
tyler09456
(RollMysts)
September 5, 2020, 5:28pm
#9
I want it to only open/close the settingsframe though.
2 Likes
lexishh
(lexishh)
September 5, 2020, 5:29pm
#10
local openbutton = script.Parent
local Gui = script.Parent.Parent.Parent.SettingsFrame
openbutton.MouseButton1Click:Connect(function()
Gui.Visible = true
if Gui.Visible == true then
Gui.Visible = false
end
end)
3 Likes
tyler09456
(RollMysts)
September 5, 2020, 5:30pm
#11
It justs hides my button and not the frame for it.
2 Likes
lexishh
(lexishh)
September 5, 2020, 5:31pm
#12
Fixed it. Edited the last post.
1 Like
tyler09456
(RollMysts)
September 5, 2020, 5:33pm
#13
It does not seem to work. Like it ain’t opening the frame or closing it.
2 Likes
lexishh
(lexishh)
September 5, 2020, 5:38pm
#14
Could you show me the developer console?
Press f9 in game after pressing the button
tyler09456
(RollMysts)
September 5, 2020, 5:39pm
#15
f9 on my pc turns my screen off.
On some computers you have to hold the fn button when pressing f keys
BarDowned
(BarDowned)
September 5, 2020, 5:42pm
#17
Assuming you’ve parented everything correctly ;
local openbutton = game.StarterGui.ScreenGui.Settings.ImageButton
local Gui = game.StarterGui.ScreenGui.SettingsFrame
openbutton.MouseButton1Click:Connect(function()
if Gui.Visible == false then
Gui.Visible = true
else if Gui.Visible == true then
Gui.Visible = false
end
end)
3 Likes
tyler09456
(RollMysts)
September 5, 2020, 5:42pm
#18
Thanks that worked! You have been a lot of help lately.
tyler09456
(RollMysts)
September 5, 2020, 5:44pm
#19
I can jump back in to studio and fix it if you want too