Do I need a New RemoteEvent for Each Player

Basic question but I’m still learning and its tough to find answers.

Reviewing the documentation for Remote Events in the Roblox API, it shows a new RemoteEvent object created in the ServerScript in every example. When I create Client-to-Server or Server-to-Client ServerScript, do I need to create a new RemoteEvent per player, per event type?

I’m specifically asking from the standpoint of firing a Client-side LocalScript from a ServerScript to change their GUI. If all Clients have a LocalScript listening for the Event, I’m assuming they would either have to have their own RemoteEvent or we are passing the player parameter in the FireClient(player) function?

Here is the example below from the API showing that it creates a new RemoteEvent. Would this be necessary if I have already created the RemoteEvent in ReplicatedStorage?

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local welcomePlayerEvent = Instance.new("RemoteEvent")
welcomePlayerEvent.Parent = ReplicatedStorage
welcomePlayerEvent.Name = "WelcomePlayerEvent"

local function onPlayerAdded(player)
	welcomePlayerEvent:FireClient(player)
end

Players.PlayerAdded:Connect(onPlayerAdded)

So basically if you say put a local script inside of a gui then that would get replicated to every user then on the server you can do 2 types of event:

  1. Specify the player as you have done in your code
  2. Fire all the clients which is everyone in the game
1 Like

That makes sense. So just to confirm, I would NOT need a new RemoteEvent per player? That code was taken directly off the API and seems to create a new RemoteEvent every time it is fired.

You do not need a separate remote for each player, the first parameter for RemoteEvent's FireClient method is the client (the player) you are trying to fire the event for.

1 Like

nope all you would need is one remote and as long as it is in replicated storage then it could be access by a local script and fired by it while also being able to be fired by the server

1 Like

Thanks guys, that was super quick.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.