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

How to open a ScreenGui by clicking part of the model?

1 answer

✓ Accepted answer

I have found a way to do this..

So what you need to do first is, put a part in the workspace and add a: clickdetector, and a normal script ( not local script ) inside of the part.

Then add a remote event inside of replicated storage, call it anything ( i called mine OpenGuiEvent).

Then add a screen gui into starter gui. And put a frame inside of the screen gui and a local script inside of the screen gui too.

For the script inside of the part, the code is:

local replicatedStorage = game:GetService("ReplicatedStorage")
local OpenGuiEvent = replicatedStorage:WaitForChild("OpenGuiEvent")

local part = script.Parent
local clickDetector = script.Parent.ClickDetector


clickDetector.MouseClick:connect(function(Player)
	OpenGuiEvent:FireClient(Player)
end)

if you named your remote event to something else, change the variable obviously.

Then for the local script inside of the screen gui, i put in:

local replicatedStorage = game:GetService("ReplicatedStorage")
local OpenGuiEvent = replicatedStorage:WaitForChild("OpenGuiEvent")

local gui = script.Parent
local frame = script.Parent:WaitForChild("Frame")


OpenGuiEvent.OnClientEvent:connect(function()
	frame.Visible = true
end)

Before you test it out, make sure you make your frame invisible in the properties tab before you run the game.

To close the gui add in a textbutton inside of the frame. I make the text button a small square shape and I change the text to a capital x to make the close button. I also change text scaled to true and change the background transparency to 1

The code inside of the local script in the frame is:

local frame = script.Parent
local closeButton = script.Parent.closeButton

closeButton.MouseButton1Click:Connect(function()
	frame.Visible = false
end)

I hope this works for you.

4 comments

0

thx

0

your welcome :) did it work?

0

yes, but what is the script that closes the script when the button is pressed?

0

I edited the response. I hope you find this useful.

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