Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script for a GUI?

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?

2 comments

0

Please add the code into a LUA Code Block...

0

Do not duplicate your question.

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.