Chat system messages local

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want every player in the server to see the chat system message.
  2. What is the issue? Include screenshots / videos if possible!
    When a player steps on a block, the chat system message only says for them.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked at YouTube videos and didn’t find anything. The topics I found on the devforum didn’t have the same problem as me. If you do find one though I am sorry for posting this and please flag the topic.

This is a function from my code that makes the messages. This is a local script inside the starter gui.

local function stoptimerandgettime()
	local timertime = script.Parent.Text
	player.Character.Humanoid.Health = 0
	player.Character.HumanoidRootPart.Position = workspace.Lobby.WinnerSpawn.Position
	player.leaderstats.Towers.Value = player.leaderstats.Towers.Value + 1
	local brickcolor = BrickColor.new("Bright yellow")
	game.StarterGui:SetCore("ChatMakeSystemMessage",{
		Text = player.Name.." has beaten the tutorial tower in: "..timertime;
		Font = Enum.Font.Cartoon;
		Color = brickcolor.Color;
		FontSize = Enum.FontSize.Size96;
	})
end

Check out ChatService.

It’s an interface for Roblox’s default Lua chat. It has server APIs and client APIs all listed on that page. There’s some sample code lying around there which might be useful to you. If you’re still not sure what to do you can check out a recent project of mine that uses ChatService called ChatPlus.

More specifically, I’d recommend checking out the source code here on GitHub for how to actually use the server API.

2 Likes

Is there any way to keep the current script I have without using modules though?

You don’t need to use modules. You can use the ChatService server API in any server script you want. :slight_smile:

Assuming the code you sent there is server code, then you can replace the SetCore call the needed ChatService functions.

1 Like

I am very sorry, but I am not really understanding the ChatService server API. I read through the article and I am really confused. Can you maybe send a sample code that shows the chat service in action through a server script?

Sure!

Here’s some code that sends a system message:

local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner").ChatService)

local ServerSpeaker = ChatService:AddSpeaker("Server")
if not ChatService:GetChannel("All") then
	while wait() do
		local ChannelName = ChatService.ChannelAdded:Wait()
		if ChannelName == "All" then
			break
		end
	end
end
ServerSpeaker:JoinChannel("All")

ServerSpeaker:SayMessage("Hey everybody!", "All") --This part is this message sending bit
1 Like

Hmm so I wanted to test the sample code before actually implementing my stuff, but it didn’t seem to make a message.

Sorry about that. I edited my code to fix the issue.

You can use RemoteEvent:FireAllClients() to broadcast the message to everyone. Then listen to the .OnClientEvent event and send the system message.

Ok so @COUNTYL1MITS I have tried that just now and it still doesn’t work. Here is my code.

Function that receives:

local function stoptimerandgettime()
	local timertime = script.Parent.Text
	player.Character.Humanoid.Health = 0
	player.Character.HumanoidRootPart.Position = workspace.Lobby.WinnerSpawn.Position
	game.ReplicatedStorage.GiveTowers:FireServer()
	game.ReplicatedStorage.ChatMessageComplete.OnClientEvent:Connect(function()
		local brickcolor = BrickColor.new("Bright yellow")
		game.StarterGui:SetCore("ChatMakeSystemMessage",{
			Text = player.Name.." has beaten the tutorial tower in: "..timertime;
			Font = Enum.Font.Cartoon;
			Color = brickcolor.Color;
			FontSize = Enum.FontSize.Size96;
		})
	end)
end

Script that fires:

local debounce = false

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if not debounce then
			debounce = true
			game.ReplicatedStorage.GetTimeAndStop:InvokeClient(player)
			game.ReplicatedStorage.GiveTowers.OnServerEvent:Connect(function()
				player.leaderstats.Towers.Value = player.leaderstats.Towers.Value + 1
				print("Received remote event message and gave player a tower point.")
			end)
			game.ReplicatedStorage.ChatMessageComplete:FireAllClients()
			wait(10)
			debounce = false
		end
	end
end)