Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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
0
ScreenGui Parent set to StarterGui and still doesn't works? GodlyEricGamer1800 -100 — 5y
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 DanzLua 2879 — 5y
0
Yeah i see, it cloned to PlayerGUI, it worked, but the properties hasn't changed GodlyEricGamer1800 -100 — 5y
0
Size is set to 0, position set to 0 GodlyEricGamer1800 -100 — 5y
View all comments (5 more)
0
@GodlyEricGamer1800 What properties DanzLua 2879 — 5y
0
OH one sec. DanzLua 2879 — 5y
0
Ok GodlyEricGamer1800 -100 — 5y
0
@GodlyEricGamer1800 Edited answer DanzLua 2879 — 5y
0
Ok, working thank you GodlyEricGamer1800 -100 — 5y
Ad

Answer this question