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

How to send messages to the chat with a script?

Asked by
Valatos 166
8 years ago

So I know some games, make stuff say in the chat when you join, I'm pretty sure they don't use a custom chat. How did they do that? Or is it just a custom chat? I searched on the wiki, on YouTube, even looked for a question asked about it, but I couldn't find anything.

2 answers

Log in to vote
1
Answered by 8 years ago

In terms of your original question, you want to use the SetCore function in StarterGui (see here) for an example of this. You will need to run the script in a LocalScript for it to work, and the message will only display on the player's screen for which the script is running.

Making a custom chat script is quite a different topic and it's not something I can explain into an answer to this question, but I suggest you check out this wiki article for more information. Sorry I can't explain this in an answer, but it is a very complicated topic and it is very technical.

1
Thanks! Didn't know I would needed to use the CoreGui. Valatos 166 — 8y
Ad
Log in to vote
2
Answered by
nanaluk01 247 Moderation Voter
8 years ago

If you want the server to "Chat" when the player joins and the player leaves, you would need to put this into a LocalScript inside StarterPlayerScript:

See comments in the code to get a better insight of how this script works!

If there are any typos, then please excuse me, I wrote this code here and now.

01pcall(function() --Event that should fire when the player joins
02    game.StarterGui:SetCore("ChatMakeSystemMessage", {
03        Text = "[Server]: " ..game.Players.LocalPlayer.Name.. " has joined the game!";
04        Color = Color3.new(255, 255, 255); --The color of the text
05        Font = Enum.Font.SourceSansBold; --The font of the text
06        FontSize = Enum.FontSize.Size24; --The size of the text
07    })
08end)
09 
10game.Players.ChildAdded:connect(function(player) --Event that fires when player joined
11    if not pcall(function() --If the pcall() function was not called
12        game.StarterGui:SetCore("ChatMakeSystemMessage", { --Gets the chat
13            Text = "[Server]:  " ..player.Name .. " has joined the game!"); --Sets the text
14            Color = Color3.new(255,255,255); --Sets the color of the text
15            Font = Enum.Font.SourceSansBold; --Sets the font of the text
View all 34 lines...

For more information, visit this link: http://wiki.roblox.com/index.php?title=API:Class/StarterGui/SetCore

If this helped you out, make sure you accept the answer!

0
You don't have to use the ChildAdded and ChildRemoved event on the Players service, just use PlayerAdded and PlayerRemoving :P Valatos 166 — 8y
0
I know, this was just as an example. The script itself does the same thing. nanaluk01 247 — 8y

Answer this question