So basically, Im tryna make this code where you can send a request to a player using a gui, then a “request” gui is supposed to pop up on their screen. The only thing is, i dont know how to make it so a gui pops up on their screen when I send the request. How do I do this?
use remote event, it signals the player (assuming u have something like Event.OnClientEvent:Connect(function(Request)
–Do Stuff
end)
Some references and helpful information from the Developer documentation:
Remote Events and Callbacks | Documentation - Roblox Creator Hub for sending and receiving information from other players (sending the “request”) – I would look mostly into RemoteEvents for this case
An example I could come up with from the top of my head would be the following:
Requester: The person making a request
Recipient: The person receiving said request
→ These GUIs will have local scripts that will send these requests via. RemoteEvent
The Server: A server-side “Request handler” to send request information from one client to another
The general back-end process will most likely follow this process:
- The Requester makes a request through a RemoteEvent using the their GUI. This event will contain data such as the recipient player and whether it’s a request being sent out, a request being accepted or a request being declined.
- The Server will catch this request and forward it to the recipient player.
- The recipient player receives the forwarded request from the server. They will then decide whether they want to accept or decline this request through their GUI
- If the request is accepted, you can choose what you want to happen to the requester and the recipient (like teleporting the recipient to the requester for example). You might need to send another RemoteEvent from the recipient to The Server to do anything that needs to be handled in that context, like a transaction
- If the request is declined, you can also choose whether you want any further action to be taken on the server, like notifying the requester that the recipient has declined the request
There are many ways to create a “requesting” GUI. The way in which you do it is up to you. I won’t be giving a local script example because the code largely depends on what kind of GUI setup you choose.
Code template for The Server:
local remote: RemoteEvent = (insert path to RemoteEvent)
-- Tried to make this as simple to understand as possible. There are more effective ways
-- of setting this up, especially if you plan to send lots of data.
local function requestRemote(requester: Player, action: string, recipient: Player?)
if action == "SendRequest" then
remote:FireClient(recipient, "Request", requester) -- recipient (Player), action (string), requester (Player)
elseif action == "RequestAccept" then
-- Whatever you need to do
elseif action == "RequestDecline" then
-- Whatever you need to do
end
end
remote.OnServerEvent:Connect(requestRemote)
If you need clarification, feel free to ask.