local Tablet = script.Parent local clickDetector = Tablet.Parts.Button.ClickDetector function onMouseClick() if Tablet.Screen.SurfaceGui.Frame.Visible = false then Tablet.Screen.SurfaceGui.Frame.Visible = true elseif Tablet.Screen.SurfaceGui.Frame.Visible = false end clickDetector.MouseClick:connect(onMouseClick)
The main problem in the code is this part:
elseif Tablet.Screen.SurfaceGui.Frame.Visible = false
You are using an "elseif" statement instead of a plain "else" statement. "elseif" is used to write another "if" statement if conditions on a previous "if" statement are not met. Here is your edited code. Also, be sure to use "==" instead of "=" if you are placing conditions.
local Tablet = script.Parent local clickDetector = Tablet.Parts.Button.ClickDetector local function onMouseClick() if Tablet.Screen.SurfaceGui.Frame.Visible == false then Tablet.Screen.SurfaceGui.Frame.Visible = true else Tablet.Screen.SurfaceGui.Frame.Visible = false end clickDetector.MouseClick:connect(onMouseClick)
P.S. Please indent your code correctly. It would be useful in the future.