So I made a script for a gui so when MouseButton1Down:connect the GUI would open. It opens and closes in studio but when I go to the game, the GUI does not open or close. Did I do something wrong?
Frame = script.Parent.Frame Button = script.Parent.TextButton Open = false Button.MouseButton1Down:connect(function(open) if Open == false then Frame.Visible = true Open = true elseif Open == true then Frame.Visible = false Open = false end end)
This is most likely the fact that the script is running before the character loads, therefore the script cannot find the object it's referring to. A simple solution is adding some WaitForChild's to the beginning of the script.
-- Checking for all the loaded elements. script.Parent:WaitForChild("Frame") script.Parent:WaitForChild("TextButton") -- Check Complete. Frame = script.Parent.Frame Button = script.Parent.TextButton Open = false Button.MouseButton1Down:connect(function(open) if Open == false then Frame.Visible = true Open = true elseif Open == true then Frame.Visible = false Open = false end end)
Tell me if this doesn't work.