Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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

Log in to vote
1
Answered by
Unclear 1776 Moderation Voter
9 years ago

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)
0
ty babe dirty_catheter 7 — 9y
Ad

Answer this question