Hello,
I'm wondering if it's possible to wait until a remote event's script has ended? The question speaks for itself. If you'd like, please look through my scripts. It should make it quite obvious what I am trying to achieve.
Note that the delays are a bad and temporary solution. Thank you for your help, it is appreciated.
Local script in StarterGui.
--// Variables local RepStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local Player = Players.LocalPlayer local PlayerGui = Player.PlayerGui local ServerTextGui = PlayerGui.ServerText local ServerTextLabel = ServerTextGui.Frame.Text local NPCTextGui = PlayerGui.NPCtext local NPCTextLabel = NPCTextGui.Frame.Frame.Text local PlayerTextGui = PlayerGui.PlayerText local PlayerTextLabel = PlayerTextGui.Frame.Frame.Text local TextSound = script.TextSound local NPCText = RepStorage:WaitForChild("NPCText") local PlayerText = RepStorage:WaitForChild("PlayerText") local ServerText = RepStorage:WaitForChild("ServerText") --// Functions ServerText.OnClientEvent:Connect(function(Text) print("[SERVER] ServerTextEvent fired.") local GuiType = ServerTextGui local GuiText = Text GuiType.Frame.Visible = true for i = 1, #GuiText do ServerTextLabel.Text = string.sub(GuiText, 1, i) TextSound:Play() wait(0.05) end wait(2) ServerTextLabel.Text = "" ServerTextGui.Frame.Visible = false end) NPCText.OnClientEvent:Connect(function(Text) print("[SERVER] NPCTextEvent fired.") local GuiType = NPCTextGui local GuiText = Text GuiType.Frame.Visible = true for i = 1, #GuiText do NPCTextLabel.Text = string.sub(GuiText, 1, i) TextSound:Play() wait(0.05) end wait(2) NPCTextLabel.Text = "" NPCTextGui.Frame.Visible = false end) PlayerText.OnClientEvent:Connect(function(Text) print("[SERVER] PlayerTextEvent fired.") local GuiType = PlayerTextGui local GuiText = Text local RandomPlayer = Players:GetPlayers() local SelectedPlayer = math.random(1,#RandomPlayer) local PlayerName = RandomPlayer[SelectedPlayer] local ThumbnailType = Enum.ThumbnailType.HeadShot local ThumbnailSize = Enum.ThumbnailSize.Size420x420 local PlayerImage, isReady = Players:GetUserThumbnailAsync(PlayerName.UserId, ThumbnailType, ThumbnailSize) GuiType.Frame.Player.Image = PlayerImage GuiType.Frame.Visible = true for i = 1, #GuiText do PlayerTextLabel.Text = string.sub(GuiText, 1, i) TextSound:Play() wait(0.05) end wait(2) PlayerTextLabel.Text = "" PlayerTextGui.Frame.Visible = false end)
Server script in ServerScriptService.
--// Variables local RepStorage = game:GetService("ReplicatedStorage") local ServerStorage = game:GetService("ServerStorage") local Players = game:GetService("Players") local NPCText = RepStorage:WaitForChild("NPCText") local PlayerText = RepStorage:WaitForChild("PlayerText") local ServerText = RepStorage:WaitForChild("ServerText") local Text = "" --// function StartGame() Text = "Players are loading, please wait..." ServerText:FireAllClients(Text) wait(5) -- Unwanted manual delay, a wait-until remote event is finished-type of function should be here instead. Text = "Hello everyone, welcome to Clarenval Island!" NPCText:FireAllClients(Text) wait(5) -- Unwanted manual delay, a wait-until remote event is finished-type of function should be here instead. Text = "I'm Nathan Eyler, your tour guide for the week!" NPCText:FireAllClients(Text) wait(5) -- Unwanted manual delay, a wait-until remote event is finished-type of function should be here instead. Text = "Ugh, finally! It took such a long time!" PlayerText:FireAllClients(Text) wait(5) -- Unwanted manual delay, a wait-until remote event is finished-type of function should be here instead. Text = "I'm exhausted!" PlayerText:FireAllClients(Text) wait(5) -- Unwanted manual delay, a wait-until remote event is finished-type of function should be here instead. Text = "I can see that all of you are tired, don't worry; the cabins are not far away." NPCText:FireAllClients(Text) wait(7) -- Unwanted manual delay, a wait-until remote event is finished-type of function should be here instead. Text = "Come with me, I'll show you the way." NPCText:FireAllClients(Text) wait(5) -- Unwanted manual delay, a wait-until remote event is finished-type of function should be here instead. Text = "Follow your tour guide, Nathan. Be on the look-out for useful items!" ServerText:FireAllClients(Text) wait(5) -- Unwanted manual delay, a wait-until remote event is finished-type of function should be here instead. end wait(5) StartGame()