Why does this not work?

So i’m currently making a Announcment System. It should send the Announcment through the RemoteEvent but somehow at the end roblox gets nil somehow.

local AnnouncmentText = script.Parent.Parent.TextBox.Text
local Announcment = tostring(AnnouncmentText)
local Event = game.ReplicatedStorage.AnnouncmentEvent

script.Parent.MouseButton1Click:Connect(function(plr)
	
	Event:FireServer(plr, Announcment)
	script.Parent.Parent.Visible = false
	
end)

Thanks for your help!

nvm it does work. No replies needed anymore!

Can I ask, is this for an admin system or for everyone? Because if it’s for a specific admin system I can hook you up with a range of commands.

What is the thing your man king the command for?
(airlines, cafe, theatre…)

Its for my ro-aviation tech group as a announcment system.

ah, command or GUI?

if u need help just lmk.

GUI

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:

  1. 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.
  2. 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.
  3. 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 :sob:
1 Like

nah, it still had some bugs

I’m always here to help. Lmk if you need anything. :grin:

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