Ok so, I've been seeing some Games that have Server Messages when a player joins like for Example: [Server]: Playername has joined the server.
Anyone mind explaining how to do this? I am not talking about custom chat btw I've seen this with the normal roblox chat.
Thank you for reading & Please help.
To create such message, we'll use ChatMakeSystemMessage
. This creates a message in the chat system. Second, PlayerAdded
event, this event fires when a player joins the server.
game.Players.PlayerAdded:connect(function(player) return player end)
The event also includes a Player
argument.
Although these events/tables would help, ChatMakeSystemMessage
can only work if used in a LocalScript
using a Script
would cast an error, same with PlayerAdded
, with the exception that it doesn't error, it just doesn't corporate. A RemoteEvent/RemoteFunction
would assist.
-- Script local remote = Instance.new("RemoteEvent",game.Workspace) remote.Name = "RE" game.Players.PlayerAdded:connect(function(Player) remote:FireServer(Player) end)
-- LocalScript workspace:WaitForChild("RE").OnServerEvent:connect(function(Player) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = "[Server]: "..Player.Name.." has Joined the Server"; Color = Color3.new(0,0,0); Font = Enum.Font.SourceSansBold; FontSize = Enum.FontSize.Size18; }) end)
These messages are event generated. An efficient way of doing this is by having the client track who entered or left the server. We will be using the PlayerAdded event and the SetCore function. If you need an explanation on how to use SetCore, check out this wiki article, or one of my previous answers.
In a LocalScript, and for this script I recommend it would be under StarterPlayerScripts, you will want to connect to the PlayerAdded event and establish a function. You will want Player as a result of the PlayerAdded event of course. Once you've got the function connected, you will want to use the SetCore function and use the parameter to "ChatMakeSystemMessage" in the first argument. You will want to make a table as the second argument and have the Text property within it. All you have to do is type your message then you're good.
Final result should look like this.
game.Players.PlayerAdded:connect(function(Player) game.StarterGui:SetCore('ChatMakeSystemMessage', { Text = '[Server]: ' .. Player.Name .. ' has joined the game!' }) end)