Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
5

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

Asked by 8 years ago

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.

0
I like this question ConnorVIII 448 — 8y

2 answers

Log in to vote
2
Answered by
rexbit 707 Moderation Voter
8 years ago

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)
0
Thank you very much <3 ShadowShocks 42 — 8y
Ad
Log in to vote
3
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago

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.

Answer this question