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

Kind-of-dropdown menu for GUI not functioning?

Asked by
unmiss 337 Moderation Voter
9 years ago

So I honestly suppose this is broken because I am bad at scripting. I tried but clearly it doesn't work :P

So I have this 'Menu' GUI, with two invisible GUIs below it. I intend so that when I click on the Menu button, the two GUIs below it, Donate and Information, will become visible, and of course clickable. I suppose it's because I'm confused on how MouseButton1Down works.

If you need this AT ALL: http://prntscr.com/74k68o

My current scripting that I attempted:

print("Menugui dropdown-initiate") 
MenuHeader = game.StarterGui.ScreenGui.Frame.MenuHeader
Donate = game.StarterGui.ScreenGui.Frame.Donate
Info = game.StarterGui.ScreenGui.Frame.Information

function Dropdown()

    MenuHeader.MouseButton1Click:connect(Dropdown)
    Info.Visible = true
    Donate.Visible = true

    MenuHeader.MouseButton1Click:connect(Dropdown)
        Info.Visible = false    


    end

script.Parent.MouseButton1Down:connect(Dropdown)

I would appreciate if you could help me out. Thanks!

0
The 'MouseButton1Down' event fires when an 'TextLabel' or 'ImageLabel' is clicked on (MouseButton1Down WIKI Document: http://wiki.roblox.com/index.php?title=MouseButton1Down), also, please tab your code correctly. :) TheeDeathCaster 2368 — 9y
0
They are textbuttons, and in some other work people have coded for me, that same event has fired with a text button unmiss 337 — 9y
0
Whoops, I meant 'ImageButton' and 'TextButton', sorry. :c TheeDeathCaster 2368 — 9y

3 answers

Log in to vote
1
Answered by 9 years ago
function Dropdown()

    MenuHeader.MouseButton1Down:connect(Dropdown)
end

This part causes the script to flip out. You have an event that fires when you click a button, but inside of the function, is the same exact event.

So, what the script is doing is this

function Dropdown()
    Dropdown()
end
Dropdown()

It's causing a loop, that's why it doesn't become visible. Imagine your code like this

while true do
    wait(1)
    print("You'll never destroy me!")
end
script:Destroy()

It will never get to the line with :Destroy() because the while loop doesn't end.

Ad
Log in to vote
0
Answered by 9 years ago

When attempting to change a GUI for a user, you will need to access the GUIs through their PlayerGui object. When changing a GUI through StarterGui, the GUI won't appear changed until you reset and it will be changed for everybody. In order to fix this, please use a LocalScript and access their PlayerGui throguh game.Players.LocalPlayer.PlayerGui. If you have any other questions, feel free to ask me.

0
LocalPlayer @ PlayerGui don't exist until you test-play the game unmiss 337 — 9y
0
You have to have a player in the game for GUIs to do anything. FearMeIAmLag 1161 — 9y
Log in to vote
-1
Answered by 9 years ago

Try this

MenuHeader = script.Parent.Frame.MenuHeader
Donate = script.Parent.Frame.Donate
Info = script.Parent.Frame.Information

insted of the old things I can make the GUI for you if you want just give me a model.

Answer this question