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

How do i make a surface GUI holding a text button open a GUI?

Asked by 5 years ago

Hello there, im currently trying to make a game where u can press a text button on a surface gui on a part. Part -SurfaceGui -textbutton -localscript


frame = game.StarterGui.ScreenGui.Frame1

script.Parent.Parent.MouseButton1Click:connect(function()

frame.Visible = false

end) --- And when i try the game and i press the button it doesnt do anything, my goal is to make it open a frame, in this case called frame1 here is a picture of what im working on. !Image

0
you gotta do game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame1 Ultim8creeper 15 — 3y

3 answers

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

This is because StarterGui is a replication Service, meaning that whatever is a descendant of this Service will be promptly relocated to the PlayerGui Service on the Client's connection to the Server. Afterwards, any affirmations made to any descendants of StarterGui will not replicate, though will still manipulate the Instance accordingly, again.

This is primitively because this Service is meant for the Sever itself, usually to store any UI-related work for when the Player begins the Game.


The PlayerGui is the Service that will take on the job for handling the User-Interface from there forward, so to properly display the desired outcome, you must reference the Frame as a descendant of PlayerGui to see results.


Change game.StarterGui to game.Players.PlayerGui.


Additional Notes:

The MouseButton1Click method wouldn't work on a SurfaceGui Object, it must be GUIButton for this method to register according to the ROBLOX Developer Wiki.

Instead, write script.Parent for the TextBox; if this is actually restrictive to GUIButtons, then you'll have to replace the TextBox with a TextButton.

Ad
Log in to vote
-2
Answered by 5 years ago
Edited 5 years ago
frame = game:GetService("Players").LocalPlayer--to access the local player

script.Parent.Parent.MouseButton1Click:connect(function()--when the button is clicked it runs the function

frame.PlayerGui.ScreenGui.Frame1.Visible = true--makes the frame visible

end)
0
also accept my answer please Gameplayer365247v2 1055 — 5y
0
This isn't correct.. Ziffixture 6913 — 5y
Log in to vote
-2
Answered by
vissequ 105
5 years ago
Edited 5 years ago

The StarterGui and the PlayerGui are different things. The StarterGui is where all the GUIs are held and whenever a player joins the game all the GUIs in the StarterGui are moved into the PlayerGui. This is important because if you are editing something in the StarterGui, it will not be seen by players who have already joined. You would want to modify the PlayerGui. I don't know how to get a player from a text button on a surface gui but with a click detector you can pass through the Player like this:

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

    plr.PlayerGui.NameOfGui.Frame.Visible = true

end)

Worst case you could just put a part in front of the button that is invisible and put a click detector in it.

0
B.S. DeceptiveCaster 3761 — 5y
0
Not BS. You are an idiot. vissequ 105 — 5y

Answer this question