Help with coding chat messages

I have this script that gets a message from a server script and I want it to turn into a chat message.

I can only get the message to print into the Output and I can’t get it to make a message in roblox chat

My current code

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local chatService = game:GetService("Chat")

game.ReplicatedStorage.ChatSender.OnClientEvent:Connect(function(message)
	print(message)
	game.StarterGui:SetCore("ChatMakeSystemMessage",{
		Text = message,
		Font = Enum.Font.SourceSansBold,
		Color = Color3.fromRGB(255,255,255),
		FontSize = Enum.FontSize.Size96
	})
end)
2 Likes

Roblox changed their chat system. You now need to use TextChatService. I normally don’t give out code but here’s a quick way on how to create a repeating cycle of repeating chat messages:

-- services
local textChatService: TextChatService = game:GetService("TextChatService") :: TextChatService

-- variables
local textChannels: Folder = textChatService:WaitForChild("TextChannels", 100) :: Folder
local generalChannel: TextChannel = textChannels:WaitForChild("RBXGeneral", 100) :: TextChannel

local chatMessages: any = {
	"Hello, I'm awesome!",
	"Wow, it works?",
}

-- functions
while (true :: boolean) do
	generalChannel:DisplaySystemMessage(chatMessages[math.random(#chatMessages)])

	task.wait(360)
end

Here is a link to the TextChannel class: TextChannel

Additional text:

In your case you have a RemoteEvent which is sending data to the client. So you can try something like this:

-- services
local textChatService: TextChatService = game:GetService("TextChatService") :: TextChatService

-- variables
local textChannels: Folder = textChatService:WaitForChild("TextChannels", 100) :: Folder
local generalChannel: TextChannel = textChannels:WaitForChild("RBXGeneral", 100) :: TextChannel

-- functions
RemoteEvent.OnClientEvent:Connect(function(message: string)
    generalChannel:DisplaySystemMessage(message :: string)
end)
2 Likes

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