Hello
What is the right way from a server script to invoke GUI popup on the client and get the input?
step 1. In the server script send remote event to the client
step 2. handle the remote event in a local script and make the gui popup enabled/visible.
step 3. handle user input in a local script and send different remote event to the server
step 4. handle the remote event and the client input in a server script on the server.
Is this the best sequence or there are more simplified options?
Are there ways to modify/show the GUI popup for a certain player directly from a server script?
Yes ,in fact this is my question
is the standard procedure in this case to use 2 remote events? And is it bad to modify the GUI for given player from the server script…
Because I want to trigger the GUI popup from a Click detector, which is handled in a server script. Then in the server script I have to send a remote event, which will be handled by a local script and which will show the popup. Then when the user interacts with the popup I have to send a remote event to the server, which will be handled by another server script.
The code needs to be put in multiple places and becomes too decoupled. So I was wondering if there is a better way…
Yeah so I would have 2 remotes so it’s easier to visualise, but you can use the same remote.
-- Click Detector Pressed
local OpenUI = RemoteEvent -- RemoteEvent here
OpenUI:FireClient(player)
-- Client Side
local OpenUI = RemoteEvent -- RemoteEvent here
OpenUI.OnClientEvent:Connect(function()
-- Open UI
end
Simple enough to get the UI open now to send data back to the server you can use the same Remote or create a new one. For this example I will stick with one.
-- Client Side
-- When you want to send it to the server
OpenUI:FireServer(...)
-- Server Side
OpenUI.OnServerEvent:Connect(function(player, ...)
print(player.Name.." sent: ", {...})
end)