Why is this happening?

sorry for music

script inside prox (serverscript)

local prox = script.Parent

local gui = player.PlayerGui.PictureFrameGui
gui.Enabled = true

local script inside exit button

local exitButton = script.Parent

local mainGui = exitButton.Parent

mainGui.Enabled = false


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.

1 Like

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.

1 Like

you cant trigger on the client i dont think

Are you sure? I don’t have access to studio right now but I thought that the proximity prompt’s Triggered event works on client side.

ya i tested it out it didnt work

this worked though so think is good

If it works, do mark this as the Solution of this topic, so others who are facing similar problems could find a solution easily!

I tested it now and it works:

-- LocalScript in StarterPlayerScripts

	print("Client Side")

I found a better way:
This goes into your close button
Roblox help1

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

button.Activated:Connect(function() -- if the button "X" for is click or activated then.
	Gui.Enabled = false -- your gui will be disabled

If you need me to script one that does more than one proximity prompts in the game then let me know!