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
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
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)
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
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)
Yeah I forgot the GetNonChatStringForBroadcastAsync
function. Thanks for the corrections
Thanks for all that i will try it
It works same as before only 1 client can see the announcement
Make sure you use :FireAllClients()
Can you send your client script?
Here is the client script
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
Let me do that and see if it works
Before the Wait line. You should not use Textbox.Text . You need to use the message Variable.
player.PlayerGui.AnnouncementGui.Frame.TextLabel.Text = message
I was about to say I must have overlooked something. Thanks for pointing that out haha
Thanks for everything, now the annoucement system works
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.