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

How this script failed?

Frame2 = game.StarterGui.ScreenGui.Frame
Button = script.Parent

function onClick()
	Frame2.Visible = true
end

Button.MouseButton1Click:connect(onClick)

What is wrong!?

2 answers

StarterGui is where you put GUI's that will replicate to the player's PlayerGui. You edit the GUI in PlayerGui to display any changes instantly.

-- LocalScript in the ScreenGui
local plr = game.Players.LocalPlayer
--You may need to fix these
local Frame2 = script.Parent:WaitForChild("Frame")
local Button = Frame2:WaitForChild("TextButton")

function onClick()
	if Frame2.Visible then 
		Frame2.Visible = false
	else
 	   Frame2.Visible = false
	end
end

Button.MouseButton1Click:connect(onClick)

Several Things that might brake the script...

I am not positive, but "MouseButton1Click" may be wrong. Even if it is technically correct, try something like MouseButton1Down

Try messing around when the arguments in the function. A variable might not be carrying over

  1. It may just be the formatting on scriptinghelpers, but to me the computer sees Frame2 as "Frame" "2" not one name of "Frame2"

Hope this helps!

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