While working on an ongoing project, I ran into the dilemma of having to run two remote functions right after the other. I planned on using the wait function in order to wait for the events to finish, however it will only wait for the event to fire.
To solve this, I tried waiting for an object that would be copied from the main server to the PlayerGui on the ServerScript, however, I haven't found the correct way of waiting for the object to be removed.
function OnClicked()
game.ServerScriptService.MainGui.ChatNote:InvokeServer("Num1","Text1")
-- Asks the server to set a Gui title to "Num1" and text to "Text1"
local noted = script.Parent.Parent.Parent:WaitForChild("ChatNote")
-- Waits till "ChatNote" is added
wait(noted == nil)
-- Does not wait
game.ServerScriptService.MainGui.ChatNote:InvokeServer("Num2","Text2")
-- Same as line 2
end
script.Parent.MouseButton1Down:connect(OnClicked)
Any comments are appreciated and thank you.

1 comment
This is by no means the optimal solution but you can run a repeat loop. repeat wait() until notel==nil