:FireAllClients()
does not have ANY required arguments, which means you don't need your playerAdded
or playerRemoved
. I'm not saying that you can't send them through the remote (you need to in this instance, as I'll show below), but that means that you have to adjust your OnClientEvent
's parameters, again, as shown below.
01 | local Players = game:GetService( "Players" ) |
02 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
03 | local RemoteEvent = ReplicatedStorage:WaitForChild( "PlayerJoinedorRemoved" ) |
05 | Players.PlayerAdded:Connect( function (playerAdded) |
06 | RemoteEvent:FireAllClients(playerAdded, "Joined" ) |
09 | Players.PlayerRemoving:Connect( function (playerRemoved) |
10 | RemoteEvent:FireAllClients(playerRemoved, "Left" ) |
01 | local StarterGui = game:GetService( "StarterGui" ) |
02 | local Players = game:GetService( "Players" ) |
03 | local Player = Players.LocalPlayer |
04 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
05 | local RemoteEvent = ReplicatedStorage:WaitForChild( "PlayerJoinedorRemoved" ) |
07 | RemoteEvent.OnClientEvent:Connect( function (playerToDisplay,action) |
08 | if action = = "Joined" then |
09 | game.StarterGui:SetCore( "ChatMakeSystemMessage" , { |
10 | Text = (playerToDisplay.Name.. " has joined the server." ); |
11 | Color = Color 3. fromRGB( 121 , 255 , 188 ); |
12 | Font = Enum.Font.ArialBold; |
15 | elseif action = = "Left" then |
16 | game.StarterGui:SetCore( "ChatMakeSystemMessage" , { |
17 | Text = (playerToDisplay.Name.. " has left the server." ); |
18 | Color = Color 3. fromRGB( 255 , 51 , 71 ); |
19 | Font = Enum.Font.ArialBold; |
So let's go over what really happens in the local script. When you define LocalPlayer
, it is the player that the remote event is sending to. In this case, that is EVERY player, because you are firing all clients. This means that you need to store the player who joined (which we did in the PlayerAdded
event). Of course, we do the same for PlayerRemoving
. Next, we adjusted the parameters for OnClientEvent
.
There are no required arguments for :FireAllClients()
so that means anything else you send is being sent as a variant, so it will need to be placed as a parameter for OnClientEvent
. Otherwise, it will disturb the order of the parameters. This means that in your original code, when you used action
as the parameter for OnClientEvent
, it wasn't really Joined
or Left
. Instead, it was the player that joined or left.
Let me know if you have any further questions!