Im trying to make a system where for example: Player1 can send a request to Player2. Once Player2 receives this request with OnClientInvoke(), a GUI is supposed to appear to give the option to accept or deny the request.
This is done by a single remote event (Named: RequestHandler)
I’m trying to make Player1 send a request to the server with RequestHandler, then the server sends a request to Player2 using again, RequestHandler.
This happens between 3 scripts, which will be shown later.
However, when the button is pressed to send the request via InvokeServer(), nothing happens.
No error is thrown in the Output and the GUI doesn’t appear or change at all.
Local Script 1 – This is where the button is pressed by Player1 to send the request to the server via InvokeServer() … step 1 of the process
local sendRequestButton = script.Parent
local remoteFunctions = game.ReplicatedFirst.RemoteFunctions
sendRequestButton.MouseButton1Click:Connect(function(plr)
local sentByPlayerID = game.Players:GetUserIdFromNameAsync(game.Players.LocalPlayer.Name)
local selectedPlayerID = script.Parent.SelectedPlayerID.Value
local requestResult = remoteFunctions.RequestHandler:InvokeServer(selectedPlayerID, sentByPlayerID)
end)
Script 1 – This is where the Server Receives the initial request, then sends the actual request to the client (Player2) via InvokeClient() … step 2
local remoteFuncitons = game.ReplicatedFirst.RemoteFunctions
remoteFuncitons.RequestHandler.OnServerInvoke = function(selectedPlayerID, sentByPlayerID)
local clientName = game.Players:GetNameFromUserIdAsync(selectedPlayerID)
local requestResult = remoteFuncitons.RequestHandler:InvokeClient(clientName,selectedPlayerID,sentByPlayerID)
return requestResult
end
Local Script 2– This is where Player2 receives the request from the server, and attempts to make the GUI Visible and fill in all the necessary information, completing the process … Step 3
local remoteFunctions = game.ReplicatedFirst.RemoteFunctions
local requestUI = script.Parent.RequestUI
remoteFunctions.RequestHandler.OnClientInvoke = function(selectedPlayerID, sentByPlayerID)
requestUI.Name.Text = game.Players:GetNameFromUserIdAsync(game.Players:GetNameFromUserIdAsync(sentByPlayerID))
requestUI.UserIcon.Image = game.Players:GetUserThumbnailAsync(sentByPlayerID, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
requestUI.Visible = true
for i = 5, 0, -1 do
requestUI.YesButton.MouseButton1Click:Connect(function()
requestUI.Click:Play()
requestUI.Visible = false
return true
end)
requestUI.NoButton.MouseButton1Click:Connect(function()
requestUI.Click:Play()
requestUI.Visible = false
return false
end)
requestUI.CountDown.Text = string.format(i)
wait(1)
end
end
To clarify, no error is thrown in the Output and nothing happens to the GUI…
Any thoughts and ideas are welcomed. Sorry for messy scripts as Im still building most of it. Hopefully this post is coherent as I have been working on this for hours and im starting to get tired
Thank you for any and all help!!!