How do I have a script / the server send a message in chat?

I just can’t find the documentation for it / what things to use.

I currently want all clients to see the message, which could be something like “[Player] has died!”

--Server Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

ServerStorage.PlayerDied.Event:Connect(function(player: Player)
	local message = `<b>{player.Name}</b> has died!`
	ReplicatedStorage.ChatRemote:FireAllClients(message)
end)
--LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextChatService = game:GetService("TextChatService")

ReplicatedStorage.ChatRemote.OnClientEvent:Connect(function(message)
	TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage(message)
end)
1 Like

Neat! What does the <b> marker do?

It is RichText, it bolds that part. RichText is very cool and you should definetly look into it. If you know HTML tags then it will be easy to learn RichText. It is used to customize text (ie make only some part of a string blue while the rest is white; add a speicifc outline to some text; underline some of the text,). It has hundreds of uses

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.