The FireServer event fires the
RemoteEvent/OnServerEvent event on the server using the arguments specified with an additional player argument at the beginning.
Since this function is used to communicate from the client to the server, it will only work when used in a
When firing from the client note that nothing has to be passed in by default (unlike firing to the client from the server - where the player is passed in).
The functionality of this function, as well as other
RemoteFunction events and functions, is well documented in this article.
The arguments passed to the
RemoteEvents: Client to Server
In order for a client to send a message to the server, it needs to fire the
RemoteEvent with the function
RemoteEvent/FireServer in a
The server meanwhile needs to connect a function to the OnServerEvent of the RemoteEvent.
When a client calls the FireServer function, any functions on the server that are connected to OnServerEvent will fire. Note that this is not immediate - the network connection between the client and server will determine how quickly this happens.
When firing a RemoteEvent from a client to the server, data can be included in the firing. By default, the functions connected to OnServerEvent will be passed the player who fired the event as the first parameter. If any other arguments are provided in the FireServer function, they will also be included in OnServerEvent after the player argument.
-- LocalScript local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = ReplicatedStorage:WaitForChild("CreatePartEvent") createPartEvent:FireServer(BrickColor.Green(), Vector3.new(10, 20, 0)) -- ======================================== -- Script local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage) createPartEvent.Name = "CreatePartEvent" local function onCreatePartFired(player, color, position) print(player.Name, "wants to create a part") local newPart = Instance.new("Part") newPart.BrickColor = color newPart.Position = position newPart.Parent = game.Workspace end createPartEvent.OnServerEvent:Connect(onCreatePartFired)