Hello developers!
Today I stumbled upon an issue while making my radio system. The client fires an event where the server will retrieve the message and make a message data table then send it down to the client. When it gets sent down to the client, it keeps saying it’s nil. Is there a replication issue?
Here is the code I used:
--server
function constructMessageData(author, message, systemMessage, team)
systemMessage = systemMessage or false
if author and message and team then
local messageData = {}
messageData.Author = author
messageData.Message = message
messageData.SystemMessage = systemMessage
messageData.Team = team
return messageData
end
end
function onRadioMessageEvent(player, channel, msg)
channel = channel or "Global"
if msg then
local filteredText = TextService:FilterStringAsync(msg, player.UserId)
local isSystem = false
if not filteredText then isSystem = true filteredText = string.format("A message was sent by %s, but failed to filter.", player.Name) end
local messageData = constructMessageData(player.Name, filteredText, isSystem, player.Team.Name)
Remotes.MessageEvent:FireAllClients("Global", {messageData})
end
end
After the table is sent down to the client, it says it’s nil. Any fixes here? Would be much appreciated.
Here’s a screenshot from the output:
Edit: Just resolved this issue myself, see the posts below.