My custom chat was working fine before but have this error now: Error is at msg = msg:GetChatForUserAsync(v.UserId) (“Attempt to call a nil value”) Relevant snippet of script below:
local msg = textService:FilterStringAsync(text, player.UserId, 1)
for _,v in pairs (game:GetService("Players"):GetChildren()) do
msg = msg:GetChatForUserAsync(v.UserId)
remote:FireClient(v, player, msg)
end
The issue here is that you’re setting the variable outside the scope (TextFilterResult) to the output you get from msg:GetChatForUserAsync(v.UserId) (a string), so when it iterates to the second player,
it’ll attempt to call [string]:GetChatForUserAsync(v.UserId).
That means it’ll output that error.
The fix would be quite simply to put local in front of msg = msg:GetChatForUserAsync(v.UserId), as that makes it so that the variable is limited to that scope.