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

ScreenGui not showing up?

Asked by 8 years ago

I apologize for such a short question, as I'm new to scripting! However, when I try to get this simple script to work, it does not, but there are no errors viewing up. I basically want it to make the "border" (which is a ImageLabel) visible when I click on the button.

script.Parent.MouseButton1Click:connect(function()
game.StarterGui.ScreenGui.border.Visible = true
end)

1 answer

Log in to vote
2
Answered by
dyler3 1510 Moderation Voter
8 years ago

You problem is that you're attempting to use the StarterGuito change the objects properties. Here's a brief explanation for that:

When a player joins a game, they have a descendant service called PlayerGui. When the PlayerGui is loaded, everything from the games StarterGui gets copied into the PlayerGui. Everything that is in the PlayerGui is what the player actually sees on their screen, nothing from the StarterGui is visible to them.


So now, to fix your code.

Basically, all we have to do is be able to track the player, then we will be able to change the objects in the PlayerGui. This is a way we could achieve that:

First, change the Script you're using to a Localscript if it's not one already.

Next, we can begin the code with this:

local Player = game.Players.LocalPlayer

This gets the local player from the client. (More on that here)

Lastly, we simply need to add in the rest of the code, and edit it a bit:

script.Parent.MouseButton1Click:connect(function()
    Player.PlayerGui.ScreenGui.border.Visible = true
end)

And there you go!


Now, when we put those two things together, this is the final product:

local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    Player.PlayerGui.ScreenGui.border.Visible = true
end)

Anyways, I hope this helped. if not, or if you have any further problems/questions, please leave a comment below, and I'll see what I can do.

0
Thank you so much! It helped greatly, and thank you for the awesome explanation, it was clear and understanding. toughjohncena1256 57 — 8y
0
Awesome! Glad you were able to understand it. I'm always happy to help. dyler3 1510 — 8y
0
Dang dyler3, you have the patience to write out all that information to him. I like to help people with things but typing all that out is too much :P FiredDusk 1466 — 8y
Ad

Answer this question