So.. I have made a button(SurfaceGui) and when you click it, a ScreenGui opens. But i'm not sure why its not working.
1 | function wopen() |
2 | game.StarterGui.ScreenGui.Frame.Visible = true |
3 | end |
4 |
5 | script.Parent.MouseButton 1 Click:connect(wopen) |
Its not working because the players got playergui.
so u have to go via LocalPlayer.PlayerGui.ScreenGui.Frame.Visible
1 | function wopen() |
2 | game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true |
3 | end |
4 |
5 | script.Parent.MouseButton 1 Click:connect(wopen) |
it would be easier to just do this.
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true |
3 | end ) |
it just looks simpler and is easier to understand. :\
Ok, in order to do this, you need to put a SurfaceGui inside of the StarterGui, then insert this script into it:
1 | 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:
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true --Gets the LocalPlayer and sets the Frame to visible. |
3 | 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