Cannot open GUI after closing GUI

Need to open a gui using a proximityprompt, close it using a textbutton.

Essentially, i can open the gui with the proximityprompt, but after closing it using the close button, i cannot open it.

I cant really figure out much but to ask since I am far from a programmer, and do not know whats wrong. I would assume its just something making the game think that the close button is held rather than pushed.

Open script

local gui = game.workspace.ToolShopPart.ProximityPrompt
local shop = script.Parent.ToolShop.Frame
gui.Triggered:Connect(function()
	script.Parent.ToolShop.Frame.Visible = true
end)

Close script

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

The closescript is a local script inserted within the textbutton,
The openscript a script that is inserted within startergui, that references a proximityprompt in workspace.

Make sure that it’s setting ToolShop.Frame to invisible & not something else.
Also I’m pretty sure it’s best to use Activated over MouseButton1Click

No, Both do the Same thing but have different purposes.

1 Like

I just saw an error, you are assigning the Variable shop but never using it, and it clearly has to be used in the Function, do:

local gui = game.workspace.ToolShopPart.ProximityPrompt
local shop = script.Parent.ToolShop.Frame
gui.Triggered:Connect(function()
	shop.Visible = true
end)

Your opening the gui on the server, but closing it on the client. The client doesn’t change anything on the server. So, when the server is told to make it visible, it doesn’t. This is because on the server, nothing ever changed due to the fact the closing was on the client.

You’re opening via the server, but closing it on the client. This means server still thinks the GUI is open.

What you should have is another LocalScript in StarterGUI:

local proximity = game.Workspace.ToolShopPart.ProximityPrompt
local gui = game.StarterGUI.ToolShop.Frame

proximity.Triggered:connect(function()
    gui.Visible= true
end)

If I’m not mistaken, making the GUI visible with a server script will make it visible for every player in the server as well.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.