So basically, you’re encountering an issue where nil is being received on the server side when trying to access Announcment variable. I’m an experienced scripter here, and there could be a couple of reasons for this. I put a few things to check and adjust:
Make sure the TextBox exists and has text: Make sure that TextBox exists as a child of script.Parent.Parent, and it has some text in it. If there’s no text or the TextBox doesn’t exist, AnnouncmentText will be nil, leading to Announcment being nil as well.
Path-check the ReplicatedStorage path: Also make sure that AnnouncmentEvent exists within ReplicatedStorage. If AnnouncmentEvent is nil, calling FireServer on it will result in an error.
Check the server-side script: Make sure that the server-side script is correctly set up to receive the announcement. It’s expecting two arguments (player and announcement) when the RemoteEvent is fired, so go over if that’s exactly how it’s going.
I made a modified version of your code with some error handling lol:
local Event = game.ReplicatedStorage.AnnouncmentEvent
script.Parent.MouseButton1Click:Connect(function(plr)
local AnnouncmentText = script.Parent.Parent.TextBox.Text
if AnnouncmentText ~= "" then
Event:FireServer(plr, AnnouncmentText)
script.Parent.Parent.Visible = false
else
warn("Announcement text is empty!")
end
end)
On the server-side script, pls double-check you’re receiving the parameters correctly:
local Event = game.ReplicatedStorage.AnnouncmentEvent
Event.OnServerEvent:Connect(function(player, announcement)
if announcement then
-- ok so u handle the announcement here
print("Received announcement from", player.Name, ":", announcement)
else
warn("Received nil announcement!")
end
end)
Please also send a screenshot of your output next time, that helps in tricky cases.
edit: bruh i literally just saw that you got it fixed already smh