How to fix my announcement system

Hello I made this annoucement system but the thing is that when i send the annoucements it only shows for the player that send it. how can i make that the whole server can see it
image

1 Like

For starters, you should be filtering any inputs by players for an Announcement system with TextService:FilterStringAsync() . You will need to use Remote events to have this displayed with all clients. Since your collecting User Input on the client, and you need the server to reach other clients

1 Like

Extending onto what @OfficialPogCat said:

You should definitely be using FilterStringAsync to make sure bad messages don’t get displayed. Here’s how I’d do it:

-- Client script that you currently have:

local YOUR_EVENT = path.to.your.remoteevent

sendButton.MouseButton1Click:Connect(function()
YOUR_EVENT:FireServer(textbox.Text)
end)

YOUR_EVENT.OnClientEvent:Connect(function(message)
-- your code that displays the message (cuz im too lazy to type it out)
end)
-- Server script
YOUR_EVENT.OnServerEvent:Connect(function(Player, message)
local FilteredString = game.TextService:GetNonChatStringForBroadcastAsync(game.TextService:FilterStringAsync(string, Player.UserId))
if FilteredString then
YOUR_EVENT:FireAllClients(FilteredString)
end
end)
2 Likes

or you can loop through all the players and clone the text then add it to debris service to get rid of it after a certaint time

1 Like

You missed the player spot in your remote event. And Also you don’t filter a String like this btw. It should be :

YOUR_EVENT.OnServerEvent:Connect(function(Player, message)
  local FilteredString = game.TextService:FilterStringAsync(message, Player.UserId)
  local TextToDisplay = FilteredString:GetNonChatStringForBroadcastAsync() 
    if TextToDisplay then
      YOUR_EVENT:FireAllClients(TextToDisplay)
    end
end)
2 Likes

Yeah I forgot the GetNonChatStringForBroadcastAsync function. Thanks for the corrections :sweat_smile:

1 Like

Thanks for all that i will try it

1 Like

It works same as before only 1 client can see the announcement

1 Like

Make sure you use :FireAllClients()


there is fire all clients

1 Like

Can you send your client script?

1 Like

image
Here is the client script

1 Like

Seems like it should work. Also use task.wait instead of wait. Try adding some prints to ensure that the client(s) are receiving the signal

1 Like

Let me do that and see if it works

1 Like

Before the Wait line. You should not use Textbox.Text . You need to use the message Variable.

player.PlayerGui.AnnouncementGui.Frame.TextLabel.Text = message

3 Likes

I was about to say I must have overlooked something. Thanks for pointing that out haha

1 Like

Thanks for everything, now the annoucement system works :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.