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

Slight Gui problem?

Asked by
leepko 10
8 years ago

I need a little help with my gui, everything works but I only want my about info to show up when the button is pressed, and it's showing up when the game is loaded, it can be exited but I want it to only be up when you open it

Player = game.Players.LocalPlayer
Menu = script.Parent
Play = Menu:WaitForChild("Play")
About = Menu:WaitForChild("About")
HasPressedPlay = false
Info = script.Parent:WaitForChild("Info")
Minimize = Info:WaitForChild("Minimize")

function MouseEnterPlayButton()
    Play.FontSize = "Size36"
    Play.Size = UDim2.new(0.45, 0, 0.160, 0)
end

function MouseLeftPlayButton()
    --166, 166, 166
    Play.FontSize = "Size24"
    Play.Size = UDim2.new(0.3, 0, 0.15, 0)
end

function MouseEnterAboutButton()
    About.FontSize = "Size36"
    About.Size = UDim2.new(0.45, 0, 0.160, 0)
end

function MouseLeftAboutButton()
    --166, 166, 166
    About.FontSize = "Size24"
    About.Size = UDim2.new(0.3, 0, 0.15, 0)
end

function PlayGame()
    if HasPressedPlay == false then
        for GuiMove = 1, 30 do
            if GuiMove <= 30 then          
                    Play.Position = Play.Position +UDim2.new(0.06, 0, 0, 0)
                end
                if GuiMove <= 20 then          
                    About.Position = About.Position +UDim2.new(0.05, 0, 0, 0)  
                end
                wait()
            end

        Menu:remove()  
    end 
end

function MinimizeInfo()
    Info.Visible = false
end

function InfoPopup()
    if Info.Visible == false then  
        Info.Visible = true
    else
        Info.Visible = false
    end
end

About.MouseButton1Down:connect(InfoPopup)
Minimize.MouseButton1Down:connect(MinimizeInfo)
Play.MouseLeave:connect(MouseLeftPlayButton)
Play.MouseEnter:connect(MouseEnterPlayButton)
About.MouseLeave:connect(MouseLeftAboutButton)
About.MouseEnter:connect(MouseEnterAboutButton)
Play.MouseButton1Down:connect(PlayGame)
0
Are you setting the Gui to be not Visible by default? Your function gets triggered only when the mouse click the About button... TheArmoredReaper 173 — 8y
0
No, but I'm new to gui's so could you tell me how to make it invisible by default? It would be much appreciated leepko 10 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Just select your GUI element in the Explorer tab, then go to the Properties tab and uncheck 'Visible'. Another way to do this, that will let you edit the GUI in Studio mode, but will hide it as soon as the game starts, is by adding a single line above the code that hides the GUI element.

-- First, let's get all the variables you had previously defined.
Player = game.Players.LocalPlayer
Menu = script.Parent
Play = Menu:WaitForChild("Play")
About = Menu:WaitForChild("About")
HasPressedPlay = false
Info = script.Parent:WaitForChild("Info")
Minimize = Info:WaitForChild("Minimize")

About.Visible = false -- We change the 'Visible' property of the About element to false, which makes the element invisible, but allows you to see it in Studio mode.

-- Functions and the rest of your code goes here.

I hope this helps!

~TheArmoredReaper

Ad

Answer this question