I just made a GUI that opens and closes when i click the "OpenAndClose" TextButton. But its not working and i don't know why. The GUI doesn't appears on my screen. Also the local script parent is Workspace.
local ScreenGui = Instance.new("ScreenGui") local MAINGUI = Instance.new("Frame",ScreenGui) local OpenAndClose = Instance.new("TextButton",ScreenGui) local Button1 = Instance.new("TextButton",MAINGUI) local Button2 = Instance.new("TextButton",MAINGUI) --MainGUI MAINGUI.Position = UDim2.new({0.549, 0},{0.129, 0}) MAINGUI.Size = UDim2.new({0, 390},{0, 393}) MAINGUI.Visible = false --Buttons Button1.Position = UDim2.new({0.563, 0},{0.165, 0}) Button1.Size = UDim2.new({0, 200},{0, 50}) Button1.Text = "BRICK MATERIAL CHANGE TO NEON" Button2.Position = UDim2.new({0.563, 0},{0.268, 0}) Button2.Size = UDim2.new({0, 200},{0, 50}) Button2.Text = "BRICK COLOR CHANGE" --OpenAndCloseGuiSetUP OpenAndClose.Position = UDim2.new({0.014, 0},{0.041, 0}) OpenAndClose.TextSize = 20 OpenAndClose.Text = "Open/Close Gui" Open = false OpenAndClose.MouseButton1Down:connect(function(open) if Open == false then MAINGUI.Visible = true Open = true elseif Open == true then MAINGUI.Visible = false end
Two things are wrong with this script, one you never parent ScreenGui to the PlayerGui, so it'll never be seen, and two localscripts won't work inside the workspace, except for when they are in the character.
So what you need to do is one Parent this localscript to the StarterGui and two make the script parent ScreenGui
Edit: You are also using UDim2.new() incorrectly. This takes 4 parameters, you are giving it two tables of two numbers. Simply remove {}{} inside these.
local ScreenGui = Instance.new("ScreenGui") local MAINGUI = Instance.new("Frame",ScreenGui) local OpenAndClose = Instance.new("TextButton",ScreenGui) local Button1 = Instance.new("TextButton",MAINGUI) local Button2 = Instance.new("TextButton",MAINGUI) --MainGUI MAINGUI.Position = UDim2.new(0.549, 0,0.129, 0) MAINGUI.Size = UDim2.new(0, 390,0, 393) MAINGUI.Visible = false --Buttons Button1.Position = UDim2.new(0.563, 0,0.165, 0) Button1.Size = UDim2.new(0, 200,0, 50) Button1.Text = "BRICK MATERIAL CHANGE TO NEON" Button2.Position = UDim2.new(0.563, 0,0.268, 0) Button2.Size = UDim2.new(0, 200,0, 50) Button2.Text = "BRICK COLOR CHANGE" --OpenAndCloseGuiSetUP OpenAndClose.Position = UDim2.new(0.014, 0,0.041, 0) OpenAndClose.TextSize = 20 OpenAndClose.Text = "Open/Close Gui" Open = false OpenAndClose.MouseButton1Down:connect(function(open) if Open == false then MAINGUI.Visible = true Open = true elseif Open == true then MAINGUI.Visible = false end --Parent ScreenGui ScreenGui.Parent=script.Parent --assuming script is in startergui