The FireAllClients function fires the
RemoteEvent/OnClientEvent event for each client.
RemoteEvent/FireClient, this event does not take a target player as an argument. Instead it will fire to all clients who have the same remote event connected to an OnClientEvent event.
Since this function is used to communicate from the server to the client, it will only work when used in a
The functionality of this function, as well as other
RemoteFunction events and functions, is well documented in this article.
- Data can be passed from server to client through remote events in the same way data is passed from client to server. Any extra information can be passed in as arguments to the
RemoteEvent/FireClientand FireAllClients functions. Note that the FireClient function still needs to pass the player to send the message to as the first argument.
The arguments that will be passed to all
RemoteEvents: Server to Multiple Clients
The server can send messages to the client through remote events in two ways: it can send a message to an individual client or it can send a message to every client at the same time.
To fire a message to all clients, the server needs to call
RemoteEvent/FireAllClients. Note that in this case a player does not have to be passed into the arguments (as the function fires the remote event on all of the connected clients).
To listen for this event, each client needs to connect a function to OnClientEvent.
-- Script local Players = game:GetService("Players") local newPlayerEvent = Instance.new("RemoteEvent") newPlayerEvent.Parent = game.ReplicatedStorage newPlayerEvent.Name = "NewPlayer" local function onPlayerAdded(player) newPlayerEvent:FireAllClients() end Players.PlayerAdded:Connect(onPlayerAdded) -- ======================================== --LocalScript (for each client) local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local player = Players.LocalPlayer local newPlayerEvent = ReplicatedStorage:WaitForChild("NewPlayerEvent") local playerGui = player:WaitForChild("PlayerGui") local welcomeScreen = Instance.new("ScreenGui") welcomeScreen.Parent = playerGui local newPlayerMessage = Instance.new("TextLabel") newPlayerMessage.Size = UDim2.new(0, 200, 0, 50) newPlayerMessage.Parent = welcomeScreen newPlayerMessage.Visible = false newPlayerMessage.Text = "A new player has joined the game!" local function onNewPlayerFired() newPlayerMessage.Visible = true wait(3) newPlayerMessage.Visible = false end newPlayerEvent.OnClientEvent:Connect(onNewPlayerFired)