Gui only appears once

I am trying to make a simple gui menu. When a proximity prompt in a part is triggered, it shows the gui. This works. However, whenever I make the gui invisible, the proximity prompt script will not make it appear again. The code is so simple that I don’t know what to try.

script.parent.ProximityPrompt.Triggered:Connect(function(player)
	for _, button in ipairs(player.PlayerGui.Main.Shop:GetChildren()) do
		button.Visible=true
	end
end)

The code makes the gui visible only once, and never again after that.

1 Like

Could there be something wrong with the script that makes GUI disappear? It could be a simple mistake like deleting the GUI or doing the wrong one.

“However, whenever I remove the gui”
is your local script a child of the gui? Cause if so, deleting the gui would mean you’d delete the script.
If not, you might be moving the localscript to a place where they cannot run, I’d recommend checking the devhub page on localscripts to see where they can run.

That is a typo. I’m gonna fix that. I’m simply making it invisible.

I’ve set the gui invisible without a script too, and it still doesn’t work.

Try putting it in a localscript inside of StarterPlayer → StarterPlayerScripts, not sure if it’ll help, but it’s still worth a try.

The GUI is being set visible through a script in a part in workspace.

I know, but if I remember correctly, I fixed something similar through a localscript, and I suggested you to put it in StarterPlayerScripts because localscripts cannot run in the workspace.

1 Like

That worked. I fired a RemoteEvent to the player in startercharacterscripts to show the gui. It now shows up after I close the gui and open it again. Thank you.

No problem, glad to be able to help.

1 Like