I want the script to send a global message when a player touches a part so that every server can see the system message in the chat.
1 Like
Use MessagingService to communicate to other servers, and for the server message use Chat (deprecated but unsure of new method with TextChatService
I can further elaborate if you need
how would i make the script with messagingservice
Server script
local MessagingService = game:GetService("MessagingService")
local part = workspace.Part -- or path to part
local cooldown = 10
local start = 0
local makeChatMessage = game.ReplicatedStorage.MakeChatMessage
part.Touched:Connect(function(hit)
local now = os.time()
if not game.Players:GetPlayerFromCharacter(hit.Parent) or (start ~= 0 and (now - start) < cooldown) then return end
start = now
MessagingService:PublishAsync("Make Chat Message", game.JobId)
makeChatMessage:FireAllClients()
end)
MessagingService:SubscribeAsync("Make Chat Message", function(jobId)
if jobId == game.JobId then return end
makeChatMessage:FireAllClients()
end)
Local script
game.ReplicatedStorage.MakeChatMessage.OnClientEvent:Connect(function()
game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("Player touched a part!")
end)
the message doesnt show up do i have to add something