I inserted a GUI in the Starter GUI, and in the GUI I inserted a text button called ''Jobs''. I want a script for that text button, when you click it to show up another GUI from the Starter GUI. Can you help me? I tried this: function OnClick() shop = script.Parent.Parent ----- Edit this shop.Visible = not shop.Visible end end
script.Parent.MouseButton1Down:connect(OnClick)
Is it all right?
You might refer to something like this, maybe
function OnClick() shop = script.Parent.Parent -- Edit this shop.Visible = not shop.Visible end end script.Parent.MouseButton1Down:connect(onClick)
First thing. Where are you trying to Parent the "shop" variable? If it's like you wrote above, then you're refering to a ScreenGui, right? Unless the button is under a Frame object.
Second. Why are you trying to make the Gui invisible by changing its value to "not shop.Visible"? It should be shop.Visible = false
Third. Why are there 2 "ends"? You only created 1 block (the function), so there's no need for a second end.
It should look like this
function onClick() Shop = script.Parent.Parent -- Now it refers to the ScreenGui Shop.Visible = false -- We make the first ScreenGui invisible Shop2 = game.StarterGui.Shop2 -- A second ScreenGui with the rest of the options Shop2.Visible = true -- We make the second ScreenGui visible end script.Parent.MouseButton1Down:connect(onClick)
Marked as Duplicate by Spongocardo, Redbullusa, and BlueTaslem
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?