I have a script that displays a UI once a ProximityPrompt is activated, and another script on a ‘Close’ button within the UI that closes the UI, however I’m having an issue as once the UI has been closed, it won’t open again when the ProximityPrompt is activated. I’m not sure why this is, so both scripts are below in case one of them is interferring.
Assuming the ProximityPrompt is parented to the workspace, and the GUI script is client sided. The reason why the GUI is only opening once is youre setting Visible to true on the server, then setting Visible to false on the client. Now, on your screen its gone, however on the servers side, its still visible. When you change it back to true on the server, nothing really happens, since as far as the server is concerned, its already visible. You can fix this by either making visible/non visible both on the server, or using RemoteEvents
Why not use a remote event to handle it on the client instead?
You can use something like this:
local event = game:GetService("ReplicatedStorage"):WaitForChild("OpenUI") -- a remote event called "OpenUI" should be put inside the replicated storage
local Frame = script.Parent.Parent
event.OnClientEvent:Connect(function()
Frame.Visible = true
end)
I know why, it’s because the button script is a local script. While the opening script is a Server script.
I have a simple fix.
First, create a RemoteEvent inside replicated storage.
next, update the prox script to be this:
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") -- change the RemoteEvent to the remote event's name
script.Parent.Triggered:Connect(function(player)
remote:FireClient(player)
end)
Then, create a Local Script inside of your ui and do this.
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") -- change the RemoteEvent to the remote event's name
remote.OnClientEvent:Connect(function()
script.Parent.Visible = true
end)
Should the Local Script be parented to the Continue button or the UI that’s being opened? Sorry, I’m pretty new to this stuff as you can probably tell.