I'm currently working a filtering-enabled chat UI with remote events. I'm sending arguments through these remote events. When they reach the server, the server is supposed to send these arguments to every client. When I attempt to send the argument "message" and "player.Name" when firing the server to client event, I get an error in the server script: Unable to cast value to Object
Here is my server-side script, which is the only point of interest:
local rstorage = game:GetService("ReplicatedStorage")
local chatSendServer = Instance.new("RemoteEvent",rstorage)
chatSendServer.Name = "chatSendServer"
local chatSendClient = Instance.new("RemoteEvent",rstorage)
chatSendClient.Name = "chatSendClient"
local playerName = rstorage:WaitForChild("playerName") --ignore this
local message = rstorage:WaitForChild("message") --ignore this also
chatSendServer.OnServerEvent:connect(function(player, arguments) --the server takes these arguments successfully. sending to the clients is the only problem.
local name = player.Name
local returnmsg = arguments
print("received request: name, "..name.."; message, "..returnmsg)
wait()
for _, plyr in pairs(game.Players:GetChildren()) do
chatSendClient:FireClient(name,returnmsg) --this is the line where it errors.
end
end)
I'm not sure why this doesn't work, as the client successfully sends these arguments to the server.

1 comment
ty babe