0

# how do i make my announcements gui go to every server?

8 days ago
Edited 8 days ago

here is the script inside the submit button (the announcement only goes to 1 server so help me make it go to every server by giving me an improved script):

script.Parent.MouseButton1Click:Connect(function()
script.Sound.Playing=true
local textbox = script.Parent.Parent.Text

game.ReplicatedStorage.AnnouncementEvent:FireServer(textbox)

end)


here is the script that is inside the announcement text:

game.ReplicatedStorage.AnnouncementEvent.OnServerEvent:Connect(function(player, text)
print(text)
script.Parent.Parent.Visible = true
script.Parent.Text = text
wait(5)
script.Parent.Parent.Visible = false

end)

0
give me an improved script of the submit button so the announcement text goes to every server pls and ty ;) ads_bv 29 — 8d

1
Edited 8 days ago

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.

-- ServerScript

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 -- Whitelist, to avoid cheaters.
GlobalChatData:SetAsync(game.GameId, "[@" .. caller.DisplayName .. "]: " .. message)
end
end)

GlobalChatData:OnUpdate(game.GameId, function(message: string)
AnnouncementEvent:FireAllClients(message)
end)


Now for the LocalScript.

-- 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)
-- The second argument of SetAsync in the serverscript is used here.
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.

0

It's best to use Roblox's Messaging Service. You can send a message through it easily.

local TOPIC_NAME = "Messages"
local MessagingService = game:GetService("MessagingService")

function sendMessage(message)
MessagingService:PublishAsync(TOPIC_NAME, message)
end

function onMessage(message)
-- announce message here
end

MessagingService:SubscribeAsync(TOPIC_NAME, onMessage)


If you want more functionality with MessagingService (such as allowing servers to reply to messages sent through a topic), you could try an open-source module like Messenger.