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

Why isn't this working?

When I click it, it won't work :/

function onClick()
	if game.StarterGui.ScreenGui.Frame.Visible ==false then
		game.StarterGui.ScreenGui.Frame.Visible = true
	else
		game.StarterGui.ScreenGui.Frame.Visible = false
	end
end
script.Parent.MouseButton1Click:connect(onClick)

No ideas anymore help would be... well helpful :b

2 answers

✓ Accepted answer

Don't use the StarterGui, use this:

game.Players.LocalPlayer.PlayerGui

Since this is a Gui, you should usually use a LocalScript as it prevents server lag from the Gui, and it is only happening for that Player.

Now, a better way to do this would be to connect the function right away, like so:

script.Parent.MouseButton1Click:connect(function()
end)

Doing this can save a line, and a bit of time.

Your next error would be that you are going to the StarterGui instead of the PlayerGui, which can be done as so:

Player = game.Players.LocalPlayer
PGui = Player.PlayerGui

Everything else looks fine, good luck!

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