Why is this happening?

sorry for music

script inside prox (serverscript)

local prox = script.Parent

prox.Triggered:Connect(function(player)
local gui = player.PlayerGui.PictureFrameGui
gui.Enabled = true
end)

local script inside exit button

local exitButton = script.Parent

local mainGui = exitButton.Parent

exitButton.Activated:Connect(function()
mainGui.Enabled = false
end)

2 Likes

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

workspace.Part.ProximityPrompt.Triggered:Connect(function()
	print("Client Side")
end)

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
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!