How to make global events?

Oh lol forgot it ;-; really how could i be so …

Nah, don’t blame yourself, those stuff happen

I have just fixed my previous code and it works 100%

local Players = game:GetService("Players")
local httpService = game:GetService("HttpService")
local messagingService = game:GetService("MessagingService")

function callbackFunction(serviceData)
	local decodedData = httpService:JSONDecode(serviceData.Data)
	print(decodedData.sender," : ",decodedData.message)
end

Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg) 
		local messageData = {}
		
		messageData["sender"] = player.Name
		messageData["message"] = msg -- filter message first!

		local encoded = httpService:JSONEncode(messageData)
		messagingService:PublishAsync("Chat", encoded)
	end)
end)

messagingService:SubscribeAsync("Chat", callbackFunction)
4 Likes