How to send server chat messages in a server script

Hey there,
I’ve made a random project and it works fine and all besides the part where I can only send a server chat message on the local script so it only shows up for the local player.

I’ve tried to use a RemoteEvent but that gave me an error saying I could only do it on a local script.

Here’s my script I’m using:
(Dont mind how random it is and I know its very messy, this is just a test)

local plr = game.Players.LocalPlayer.Name
local TextService = game:GetService("TextService")
local PlayerId = plr.UserId
local ChatMessageEvent = game.ReplicatedStorage.ChatMessageEvent
local button = script.Parent


-- Define Data
local dataTable = {
	{
		item = "Apple";
		weight = 80;
		rarity = "Common"
	};
	{
		item = "Pear";
		weight = 20;
		rarity = "Legendary"
	};
}

-- Build Roll Table


-- Pick Item
button.MouseButton1Click:Connect(function()
	
	local rollTable = {}
	for _, data in ipairs(dataTable) do
		for i = 1, data.weight, 1 do
			table.insert(rollTable, data)
		end
	end
	
	
	local roll = math.random(1, #rollTable)
	print("Chosen Fruit:", rollTable[roll].item, rollTable[roll].weight)
	local message = "[Server]: "..plr.." just caught a "..rollTable[roll].rarity.." "..rollTable[roll].item.."! ("..rollTable[roll].weight.."%)"
	local RarityColors = {
		["Common"] = Color3.fromRGB(103, 103, 103);
		["Legendary"] = Color3.fromRGB(73, 246, 255)
	}
	game.StarterGui:SetCore( "ChatMakeSystemMessage",  { Text = message, Color = RarityColors[rollTable[roll].rarity], Font = Enum.Font.ArialBold, FontSize = Enum.FontSize.Size24 } )
end)

Is this what you mean?

1 Like

Technically no but I think that could actually work, Thanks

1 Like

You can try :FireAllClients() with the parameter of the message and in a local script have it so it sends it.