Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Filtering enabled chat ui, unable to cast value to object?

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 answer

✓ Accepted answer

This is just a syntax issue.

The method FireClient takes in arguments as follows...

:FireClient(playerReference, ...)

You're missing a reference to the player. Fix the line (#15) to the following:

chatSendClient:FireClient(plyr, name, returnmsg)

1 comment

0

ty babe

This discussion is preserved as it was. New answers, comments, and votes are closed.