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

How do I make a SurfaceGui open a ScreenGui?

Asked by
Ulysies 50
8 years ago

So.. I have made a button(SurfaceGui) and when you click it, a ScreenGui opens. But i'm not sure why its not working.

function wopen()
    game.StarterGui.ScreenGui.Frame.Visible = true
end

script.Parent.MouseButton1Click:connect(wopen)

3 answers

Log in to vote
0
Answered by
iNicklas 215 Moderation Voter
8 years ago

Its not working because the players got playergui.

so u have to go via LocalPlayer.PlayerGui.ScreenGui.Frame.Visible

function wopen()
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true
end

script.Parent.MouseButton1Click:connect(wopen)

Ad
Log in to vote
0
Answered by 8 years ago

it would be easier to just do this.

script.Parent.MouseButton1Click:connect(function()
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true
end)

it just looks simpler and is easier to understand. :\

0
Thats what i normally would use, I'm just making it with his script, so he understands it more. iNicklas 215 — 8y
Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
8 years ago

Ok, in order to do this, you need to put a SurfaceGui inside of the StarterGui, then insert this script into it:

script.Parent.Adornee = Part --Change this to whatever part in the workspace you want it on.

That will set the SurfaceGui onto the correct block, while also allowing you to access the LocalPlayer.


Now for the next part.

Put a LocalScript inside a TextButton whose parent is the SurfaceGui. Inside that, put this script:

script.Parent.MouseButton1Click:connect(function()
        game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true --Gets the LocalPlayer and sets the Frame to visible.
end)

This should allow you to open the frame correctly.


If you do this correctly, it should work fine. Anyways, I hope I helped. If you have any further problems or questions please leave a comment below :P

Answer this question