Announcement GUI doesn't work

  1. What do you want to achieve? Keep it simple and clear!
    I want that when you write an Announcement in the TextBox and click on the “Post” Button, a GUI should pop up showing the announcement, the Username and a headshot image of the Avatar.

  2. What is the issue? Include screenshots / videos if possible!
    The announcement doesn’t show/the texts and image doesn’t change to my headshot image, username and announcement

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked on the Forum, watched Youtube videos and even asked an AI for help but even the AI got overwhelmed.

Btw I don’t have very much experience with events + the AI made some changes on the script so it may be a bit confusing and messy (I like trying things out myself lol)

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

This is my localscript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AnnouncementEvent = ReplicatedStorage.AnnouncementEvent
local plr = game.Players.LocalPlayer

local PostButton = plr.PlayerGui.StaffPanel.MainUI.Frame.PostButton
local TextBox = PostButton.Parent.TextBox

PostButton.MouseButton1Click:Connect(function()
	if #TextBox.Text > 0 then
		local username = plr.Name
		local content = TextBox.Text
		local image = "https://www.roblox.com/headshot-thumbnail/image?userId".. plr.UserId .."=1&width=420&height=420&format=png"
		AnnouncementEvent:FireServer(username, content, image)
	end
end)

And this is my Serverscript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AnnouncementEvent = ReplicatedStorage:WaitForChild("AnnouncementEvent")

local UserUI = ReplicatedStorage.Announcements.Frame.Username
local UserImage = UserUI.Parent.PlayerPicture
local ContentUI = UserUI.Parent.Post
local AnnouncementUI = UserUI.Parent

AnnouncementEvent.OnServerEvent:Connect(function(plr, username, content, image)
	UserUI.Text = username
	ContentUI.Text = content
	UserImage.Image = image
	AnnouncementUI.Visible = true
	for _, player in pairs(game.Players:GetPlayers()) do
		AnnouncementEvent:FireClient(player, AnnouncementUI)
	end
	wait(6)
	AnnouncementUI.Visible = false
end)
1 Like

Are there any errors in the console, or is it empty?

By the way, You don’t have to loop through every player, there is a function called “:FireAllClients(arguments…)”

Nope, just checked again and there are no errors regarding these scripts.

Hm, it looks to me that you are trying to change the visiblity of a UI on the server, I recommend handling UI effects on the client.

I’ve made some changes on the localscript but I think I made it even worse at this point tbh:

local AnnouncementEvent = ReplicatedStorage.AnnouncementEvent
local AnnouncementUI = game.StarterGui.Announcements.Frame
local plr = game.Players.LocalPlayer

local UserUI = game.StarterGui.Announcements.Frame.Username
local UserImage = UserUI.Parent.PlayerPicture
local ContentUI = UserUI.Parent.Post

local PostButton = plr.PlayerGui.StaffPanel.MainUI.Frame.PostButton
local TextBox = PostButton.Parent.TextBox

PostButton.MouseButton1Click:Connect(function()
	if #TextBox.Text > 0 then
		local username = plr.Name
		local content = TextBox.Text
		local image = "https://www.roblox.com/headshot-thumbnail/image?userId".. plr.UserId .."=1&width=420&height=420&format=png"
		UserUI.Text = username
		ContentUI.Text = content
		UserImage.Image = image
		AnnouncementEvent:FireServer(UserUI, ContentUI, UserImage)
		AnnouncementUI.Visible = true
		wait(6)
		AnnouncementUI.Visible = false
	end
end)```

Could you show the code that receives the AnnouncementEvent:FireClient?

Do you mean a script that receives the AnnouncementEvent:FireAllClients? If so, I don’t have one cuz I didn’t know that I needed one. I just have the serverscript that fires the Event and that’s this:

local AnnouncementEvent = ReplicatedStorage:WaitForChild("AnnouncementEvent")

local UserUI = game.StarterGui.Announcements.Frame.Username
local UserImage = UserUI.Parent.PlayerPicture
local ContentUI = UserUI.Parent.Post
local AnnouncementUI = UserUI.Parent

AnnouncementEvent.OnServerEvent:Connect(function(plr, username, content, image)
	
	AnnouncementEvent:FireAllClients(plr, AnnouncementUI)
end)```

Yea, you need a script that receives the :FireAllClients on the client side.

Here’s an example of what you could do:

AnnouncementEvent.OnClientEvent:Connect(function()

end)

Wait is that how it should work?:

  1. One client gets all the information (content, name, image) when the button gets clicked and sends it to the server
  2. The server puts everything into the announcementUI (textlabels and image) and sends that to all clients
  3. These clients receive that and make the UI visible

Is that right or am I wrong?

You’re right.

So I browsed a little bit through the devforum and changed some things in the script again and also added another localscript that receives the event again. Here’s all scripts again:
LocalScript (first script that fires the event)

local AnnouncementEvent = ReplicatedStorage.AnnouncementEvent
local AnnouncementUI = game.StarterGui.Announcements.Frame
local plr = game.Players.LocalPlayer

local UserUI = game.StarterGui.Announcements.Frame.Username
local UserImage = UserUI.Parent.PlayerPicture
local ContentUI = UserUI.Parent.Post

local PostButton = plr.PlayerGui.StaffPanel.MainUI.Frame.PostButton
local TextBox = PostButton.Parent.TextBox

PostButton.MouseButton1Click:Connect(function()
	if #TextBox.Text > 0 then
		local username = plr.Name
		local content = TextBox.Text
		local image = "https://www.roblox.com/headshot-thumbnail/image?userId".. plr.UserId .."=1&width=420&height=420&format=png"
		AnnouncementEvent:FireServer(plr.Name, TextBox.Text, plr.UserId)
	end
end)

ServerScript:

local AnnouncementEvent = ReplicatedStorage:WaitForChild("AnnouncementEvent")

local UserUI = game.StarterGui.Announcements.Frame.Username
local UserImage = UserUI.Parent.PlayerPicture
local ContentUI = UserUI.Parent.Post
local AnnouncementUI = UserUI.Parent

AnnouncementEvent.OnServerEvent:Connect(function(plr, Text)
	UserUI.Text = plr.Name
	UserImage.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=".. plr.UserId .."1&width=420&height=420&format=png"
	ContentUI.Text = Text
	AnnouncementEvent:FireAllClients(UserUI, UserImage, ContentUI)
end)

LocalScript (last script that receives the event)

local AnnouncementEvent = ReplicatedStorage.AnnouncementEvent


AnnouncementEvent.OnClientEvent:Connect(function(UserUI, UserImage, ContentUI)
	UserUI.visible = true
	UserImage.visible = true
	ContentUI.visible = true
	wait(6)
	UserUI.visible = false
	UserImage.visible = false
	ContentUI.visible = false
end)

I’m sorry for being annoying but I’m just not very experienced with events and stuff but I’m trying to learn :D.

Well, editing the StarterGui version isn’t going to help. You want to do that on the local side.

So Instead, do (in the localscript)…

local AnnouncementEvent = ReplicatedStorage.AnnouncementEvent
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local MainUI = PlayerGui:WaitForChild("Announcements")
local AnnouncementsFrame = MainUI:WaitForChild("Frame")
local UserUI = AnnouncementsFrame:WaitForChild("Username")

local UserImage = AnnouncementsFrame.PlayerPicture
local ContentUI = AnnouncementsFrame.Post


AnnouncementEvent.OnClientEvent:Connect(function(Plr, Text)
        UserUI.Text = Plr.Name
        UserUI.PlayerPicture.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=".. plr.UserId .."1&width=420&height=420&format=png"
        AnnouncementsFrame.Post.Text = Text

	UserUI.Visible = true
	UserImage.Visible = true
	ContentUI.Visible = true
	wait(6)
	UserUI.Visible = false
	UserImage.Visible = false
	ContentUI.Visible = false
end)

And do this in the Server Script

local AnnouncementEvent = ReplicatedStorage:WaitForChild("AnnouncementEvent")

AnnouncementEvent.OnServerEvent:Connect(function(plr, Text)
	AnnouncementEvent:FireAllClients(plr, Text)
end)

Okay, yeah that makes sense. In the first localscript that detects if the player has clicked the “Post” button, I have changed the line that fires the event to this:
AnnouncementEvent:FireServer(plr, Text) (I defined where the text is with local and changed TextBox.Text to just text but it still doesn’t seem to be working. I have read through the scripts again and it seems like everything is defined correctly (if I didn’t miss anything) so idk.

Sorry for bumping this topic but I just wanted to say that I found a solution myself. If anyone needs this:
Basically what I did was in the localscript I made a function that when a person clicks the “Post” button, it will edit the Announcement GUI with the text from the textbox, username and image of the player. then I just fired “Announcement posted” to the server to let it know that there is an announcement ready to be displayed. In the serverscript I then just enabled the announcementGUI. Here are the scripts if you need it:
Localscript:

SendButton.MouseButton1Click:Connect(function()
if #TextBox.Text >= 1 then
 Username.Text = Player.Name
 Post.Text = TextBox.Text
	
	local userId = Player.UserId
	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size100x100
	local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
	PlayerPicture.Image = (isReady and content) or PLACEHOLDER_IMAGE
	PlayerPicture.Size = UDim2.new(0, 100, 0, 100)
	
    ReplicatedStorage.AnnouncementEvent:FireServer("Announcement Posted!")
end
end)

Serverscript:

ReplicatedStorage.AnnouncementEvent.OnServerEvent:Connect(function(player, a)
	script.Parent.Enabled = true
	wait(10)
	script.Parent.Enabled = false
end)

Thanks to everyone for helping and sorry again for bumping this thread. :smiley:

Edit: Just tested it with 2 players and it just edits it for 1 player. Sorry for that