Hi everyone, quick question.
I'm basically sending out announcements in a game to all clients, but before doing so it individually matches the player's chat filtering settings.
I do this using a remote function to filter the chat in a server script, and then return the filtered text.
Here is my code?
Server Script:
local repStore = game:GetService("ReplicatedStorage") local TextService = game:GetService("TextService") function repStore.filterMsg.OnServerInvoke(player,msg) local success, errorMessage = pcall(function() return TextService:FilterStringAsync(msg, player.UserId):GetChatForUserAsync(player.UserId) end) if not success then warn("Error filtering text:", msg, ":", errorMessage) return end end
Local Script:
repStore.sendAnnouncement.OnClientEvent:Connect(function(msg,timer) --this is a remote event that is used for when an admin sends the announcement msg = repStore.filterMsg:InvokeServer(msg) print(msg) end)
Any suggestions would be much appreciated.
Okay your issue here is your listening for "OnClientEvent' you should be listening for "OnClientInvoke" with a remotefunction since OnClientEvent pertains to A remote event. See if that solves the problem!
Found out it was because I was returning it in the pcall function, not sure why but oh well... works now.