Although you have enabled and disabled the GUIs, both are happening not on the same side. If the Client closes the GUI, the server wouldn’t know and would think the GUI is still enabled, like what was specified in the ServerScript.
One way to workaround this would be to send a RemoteEvent from the client to the server, such that when the GUI gets closed on the Client, the Client fires a RemoteEvent to the server and the ProximityPrompt’s Script will be able to update itself when it detects the RemoteEvent has been fired.
No, it would complicate the structure of the system. It would be better if the Triggered event was operated on the client side; then both scripts would modify the Enabled property on the client side, and the server would be less loaded.
I found a better way:
This goes into your close button
local button = script.Parent -- your "X" button to "Exit"
local Gui = button.Parent.Parent -- your "GUI"
local trigger = game.Workspace:WaitForChild("Trigger").ProximityPrompt -- the parts prox in game.workspace
trigger.Triggered:Connect(function() -- if the prox from the part is triggered then.
Gui.Enabled = true -- your gui will be enabled
end)
button.Activated:Connect(function() -- if the button "X" for is click or activated then.
Gui.Enabled = false -- your gui will be disabled
end)
If you need me to script one that does more than one proximity prompts in the game then let me know!