✓ Accepted answer
In order to send a message across all servers, you need something that can be used to connect to all servers. In this case, we'll use the easiest method; a DataStore Instance.
This is a brief example of what it may look like.
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GlobalChatData = DataStoreService:GetDataStore("GlobalChatData")
local AnnouncementEvent = ReplicatedStorage:FindFirstChild("AnnouncementEvent") or Instance.new("RemoteEvent")
AnnouncementEvent.Name = "AnnouncementEvent"
AnnouncementEvent.Parent = ReplicatedStorage
AnnouncementEvent.OnServerEvent:Connect(function(caller, message)
if table.find({293895601}, caller.UserId) then
GlobalChatData:SetAsync(game.GameId, "[@" .. caller.DisplayName .. "]: " .. message)
end
end)
GlobalChatData:OnUpdate(game.GameId, function(message: string)
AnnouncementEvent:FireAllClients(message)
end)
Now for the LocalScript.
local GuiButton = script:FindFirstAncestorWhichIsA("GuiButton")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AnnouncementEvent = ReplicatedStorage:WaitForChild("AnnouncementEvent")
local StarterGui = game:GetService("StarterGui")
AnnouncementEvent.OnClientEvent:Connect(function(message)
StarterGui:SetCore("ChatMakeSystemMessage", {
["Text"] = message,
["Color"] = Color3.fromRGB(255, 180, 0),
})
end)
GuiButton.MouseButton1Click:Connect(function()
pcall(function() script:FindFirstChildWhichIsA("Sound"):Play() end)
local TextBox = script:FindFirstAncestorWhichIsA("TextBox")
ReplicatedStorage:WaitForChild("AnnouncementEvent"):FireServer(TextBox.Text)
end)
This isn't perfect, but this is a helping website. We're not here to write it for you, but I've written some of it for you with practices that I believe are necessary. Feel free to use.
1 comment
give me an improved script of the submit button so the announcement text goes to every server pls and ty ;)