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

How do I make a SurfaceGui open a ScreenGui?

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

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)

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. :\

1 comment

0

Thats what i normally would use, I'm just making it with his script, so he understands it more.

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

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