I have code that will send a system message in the chat about which player joined or left. It uses a RemoteEvent in ReplicatedStorage to send the message.
The problem is that when I join the game and I go on my alt and join the same server, the message about the player who joined was only on that player's side, or client-sided.
How can I make it server-sided?
Codes:
LocalScript:
local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("PlayerJoinedorRemoved")
Remote.OnClientEvent:Connect(function(action)
if action == "Joined" then
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = (Player.Name.." has joined the server.");
Color = Color3.fromRGB(121, 255, 188);
Font = Enum.Font.ArialBold;
})
elseif action == "Left" then
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = (Player.Name.." has left the server.");
Color = Color3.fromRGB(255, 51, 71);
Font = Enum.Font.ArialBold;
})
end
end)
Server Script:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("PlayerJoinedorRemoved")
Players.PlayerAdded:Connect(function(playerAdded)
RemoteEvent:FireClient(playerAdded,"Joined")
end)
Players.PlayerRemoving:Connect(function(playerRemoved)
RemoteEvent:FireClient(playerRemoved,"Left")
end)

1 comment
I joined the game and nothing appearing in the chat. Is that normal?