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

I'm trying to make a computer menu GUI button, why wont it work?

Asked by 6 years ago

I'm trying to make a menu button so when you press a button the menu pops up, but it's not working...

local mainscreen = script.Parent.Parent.Parent.MainPart --Screensaver

local menu = script.Parent.Parent.Parent.Parent.StartMenu --Home Menu

local loading = script.Parent.Parent.Parent.Parent.Loader --Loading screen

local homebutton = script.Parent

homebutton.MouseButton1Down:connect(function()
    menu.MainPart.Visible = true
end)

I'm a bit of a noob so go easy on me!

0
you probably have to create a picture of what those 4 parents are. Zafirua 1348 — 6y
0
Those aren't images they are GUIs CaptainAlien132 225 — 6y

1 answer

Log in to vote
0
Answered by
CjayPlyz 643 Moderation Voter
6 years ago
Edited 6 years ago

Here.

local function OnClicked ()
    local main = script.Parent.Parent.Parent.MainPart
    local menu = script.Parent.Parent.Parent.Parent.StartMenu
    local loading = script.Parent.Parent.Parent.Parent.Loader
    local homebutton = script.Parent

    menu.MainPart.Visible = true

end

script.Parent.MouseButton1Down:connect(OnClicked)

if u want to make the main part invisible if u click it again use this, this script also makes it so that u can only click it every 1 second.

local function OnClicked ()

    local db = 0 -- Sets Variable

    local hi = 0 -- Sets Variable

    if db == 0 then -- If the db is 0 then

    db = 1 -- sets db to 1

    if hi == 0 then  -- if hi is 0 then

        hi = 1 -- sets hi to 1

        local main = script.Parent.Parent.Parent.MainPart
        local menu = script.Parent.Parent.Parent.Parent.StartMenu
        local loading = script.Parent.Parent.Parent.Parent.Loader
        local homebutton = script.Parent

        menu.MainPart.Visible = true

    else  -- if hi is not 1 then

        local main = script.Parent.Parent.Parent.MainPart
        local menu = script.Parent.Parent.Parent.Parent.StartMenu
        local loading = script.Parent.Parent.Parent.Parent.Loader
        local homebutton = script.Parent

        hi = 0 -- sets hi to 0

        menu.MainPart.Visible = false

    end

    wait(1) -- waits 1 seconds before u can click the button again

    db = 0 -- sets db to 0 so you can click the button again
    else return end  -- if db is 1 then it ends
end

script.Parent.MouseButton1Down:connect(OnClicked)
0
Thanks! CaptainAlien132 225 — 6y
0
np CjayPlyz 643 — 6y
Ad

Answer this question