Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I made a GUI (By Local Script) and it's not working, why?

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

1 answer

✓ Accepted answer

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

9 comments

0

ScreenGui Parent set to StarterGui and still doesn't works?

0

@GodlyEricGamer1800 All you have to do is parent this script to startergui. The script is then parent ScreenGui to PlayerGui since when the player loads this script will be cloned to PlayerGui

0

Yeah i see, it cloned to PlayerGUI, it worked, but the properties hasn't changed

0

Size is set to 0, position set to 0

0

@GodlyEricGamer1800 What properties

0

OH one sec.

0

Ok

0

@GodlyEricGamer1800 Edited answer

0

Ok, working thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.