RemoteEvents not firing

Server RemoteEvent isn’t being fired (or the localscript is not able to listen to the event being fired) The Script is in ServerScriptService, localscript is in a textlabel stored in startergui

Server Script:

local sendText = game.ReplicatedStorage:WaitForChild("SendText")
print("d")
sendText:FireAllClients("test")

LocalScript:

local sendText = game.ReplicatedStorage.SendText

game.ReplicatedStorage.SendText.OnClientEvent:Connect(function()
	print("a")
	end)

RemoteEvent fires however when I add wait() at any point before the FireAllClients() line.

The server script is probably running before the client starts listening for the event, meaning the client receives it but doesn’t do anything about it. Try adding a task.wait(5) to the start of the server script, or better yet, listen for the PlayerAdded event, then call FireAllClients().

2 Likes

Wait for the SentText in the LocalScript.

game:GetService("ReplicatedStorage"):WaitForChild("SendText").OnClientEvent:Connect(function()
   print("a")
   end)
local sendText = game.ReplicatedStorage:FindFirstChild("SendText")

sendText:FireClient(PlayerWhoFired)
local sendText = game.ReplicatedStorage:FindFirstChild("SendText")

sendText.OnClientEvent:Connect(function(Player)
    print(Player.Name)
end)
local Send_text = game:GetService("ReplicatedStorage"):WaitForChild("SendText")

Send_text.OnClientEvent:Connect(function(text)
     print(text)
end)