"attempt to get length of number value" when putting table through remote event

When I try to print the amount of objects in a table, it works. in a server and a local scripts, but if I do the same thing after putting the table variable through a remote event, it breaks.

Server Script:

local proximityPrompt = script.Parent.ProximityPrompt

local NPC = script.Parent.Parent.Head

local RS = game:GetService("ReplicatedStorage")
local RE = RS.RemoteEvents
local Chat = RE.Chat

local waittime = 3

local chats = {"test123","bruh","gaming"}

proximityPrompt.Triggered:Connect(function(player)
Chat:FireClient(player, chats, waittime, NPC)
end)

LocalScript:

local RS = game:GetService("ReplicatedStorage")
local RE = RS.RemoteEvents
local Chaz = RE.Chat

local function ChatFired(plr, chats, waittime, NPC)
print(#chats)
end

Chaz.OnClientEvent:Connect(ChatFired)

When firing the client, “player” is not actually passed as an argument. Removing your “plr” parameter in the client-side function should solve your issue.

local function ChatFired(chats, waittime, NPC)
print(#chats)
end
1 Like