How to open frame using (ProximityPrompt) / Close frame using (GUI Button)

When I click to open it works perfectly on the second click it doesn’t work, Thanks!

Video_2022-07-31_114248.wmv (285.4 KB)

ProximityPrompt: Script

local prompt = script.Parent
prompt.Triggered:Connect(function(player)
	local PlayerGui = player:WaitForChild("PlayerGui")
	local ScreenGui = PlayerGui.MenuGUI
	local Frame = ScreenGui.MainFrame.G001

	if Frame.Visible == false then
		Frame.Visible = true
	end
	
end)

Button: LocalScript

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible = not script.Parent.Parent.Visible
end)
1 Like

its because the server cannot see the changes that are being made in the client.
you have to change the proximityprompt script to a localscript.

2 Likes

i have the exact same thing
button script, localscript inside button

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false

end)

proximity prompt thing, inside Screengui, the parent

local Prompt = game.Workspace.PutPartNameHere.ProximityPrompt
local Frame = script.Parent.Frame
Prompt.Triggered:Connect(function()
Frame.Visible = true

end)

1 Like

It worked perfectly, thanks!

1 Like