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

How do I make the Frame disappear when the Gui button is pressed?

After pressing part, Frame appears. Here's the script:

Script in part:

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)

Script in ScreenGui:


	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)

I also made the button for frame. How do I make the Frame disappear when the button is pressed?

1 comment

0

You can actually just dive into the PlayerClicked's PlayerGUI from the Server without the use of Remotes.

2 answers

✓ Accepted answer

Put this bit of code into the ScreenGui script.

guiButton = --path to button

guiButton.MouseButton1Click:Connect(function() --detect when button is clicked
	frame.Visible = false -- make frame invisible
end

Let me know if you run into any issues.

1 comment

0

Buddy, you've got a syntax error lol

yes, you dont need RemoteEvent to do this, just type this into script inside part

local click = script.Parent.ClickDetector -- getting ClickDetector inside part

click.MouseClick:Connect(function(player) -- if player clicks on part
	if player.PlayerGui:FindFirstChild("ScreenGui") then -- checking if player actually have ScreenGui (name of your gui)

		player.PlayerGui.ScreenGui.Frame.Visible = true -- if player have gui then it can make frame visible (change ScreenGui and Frame to your names)

	end -- ending if statement lol
end) -- ending function :p

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