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

Why isn't this working?

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

Don't use the StarterGui, use this:

game.Players.LocalPlayer.PlayerGui
Ad
Log in to vote
2
Answered by 10 years ago

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!

Answer this question