Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[Solved] Making a Server Message Appear In Chat Timed or Event Triggered?

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.

1 comment

0

I like this question

2 answers

✓ Accepted answer

Events/Handy tools

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.

Responsibilities and Consequences

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.

Created Code

-- 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)

1 comment

0

Thank you very much <3

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)

######Hopefully this answered your question, if so hit the accept answer button. If you have any questions, feel free to comment below.

This discussion is preserved as it was. New answers, comments, and votes are closed.