So basically, all the GUIs in my game work except for the Rules GUI This is what i put in the local script
local Frame = script.Parent.Parent.Parent.Parent.Rules.Frame script.Parent.MouseButton1Click:connect(function() if Frame.Visible == false then Frame.Visible = true elseif Frame.Visible == true then Frame.Visible = false end end)
Here's a photo of the GUIs itself: https://prnt.sc/jxwa3u
I'm not sure what it is im doing wrong. What should i change to fix this?
It won’t work since you used connect and it’s Connect.
script.Parent.MouseButton1Click:Connect(function() Frame.Visible = not Frame.Visible end)
Review:
The script changes the current Visible state of the Gui, and sets it to its opposite.
If it is true, set true to false, and vice versa.
This code should work
local Frame = script.Parent.Parent.Parent.Parent.Rules.Frame local Toggle = false script.Parent.MouseButton1Click:Connect(function() if Toggle == false then Frame.Visible = true Toggle = true else Frame.Visible = false Toggle = false end end)
Things I found that could have been not working. 1. When you connect your event to a function you used a lower case c when that is deprecated. From now on use Connect over connect. 2. I added a simple variable that is set to false. When the player clicks it I check if the variable is false. If so then open the gui and set the variable to true. Else close the gui and set the variable to false. 3. I changed the elseif statement to just else.
So you know the code above is untested. Hope this works.
On your code,
local Frame = script.Parent.Parent.Parent.Parent.Rules.Frame script.Parent.MouseButton1Click:connect(function() if Frame.Visible == false then Frame.Visible = true elseif -- ?? Nothing ?? Frame.Visible == true then Frame.Visible = false end end)
On the elseif
statement you did not state anything and I've noticed that you may have accidently misplaced it. So to fix this, you have to do this instead:
local Frame = script.Parent.Parent.Parent.Parent.Rules.Frame script.Parent.MouseButton1Click:connect(function() if Frame.Visible == false then Frame.Visible = true elseif Frame.Visible == true then -- :D Frame.Visible = false end end)