✓ Accepted answer
The other answer written here is not correct.
Remote Event do not have a member called FireAllClient. Grammatically, that is an error and Roblox makes no exception on this either. It should be, if you still intend to fire for all Clients, then you would use FireAllClients with the s. It is a fairly small mistake, but in the end, it throws you an error.
FireAllClients does not need an argument because the Remote Event fires for all the connected users. Hence, no need for the Player arguments.
To fire for a single player, you would have to specify a Player argument.
Server Sided Script
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Players = game:GetService("Players");
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent");
local function Fire_Players (Player)
RemoteEvent:FireClient(Player);
end;
Players.PlayerAdded:Connect(Fire_Players);
Client Sided Script
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent");
local function On_Client_Event ()
print("HI");
end;
RemoteEvent.OnClientEvent:Connect(On_Client_Event);
Do keep in mind that, you do not always have to use Players Service to get the Players. There are also other ways and that can be used as well.
Resources to learn
1 comment
Do accept the answer so we can both iearn some reputation points.