Filtering System to my Chat (SOLVED)

Hello, I’m Bunnyh_Script. I’m creating a Custom Chat… The Chat Script are okay. But I can’t figure out how to make a working Filter System. I already checked the wiki, but I still can’t do it.

The Script that I’m currently using:

-- Variables
local TextService = game:GetService('TextService')

local Events = game.ReplicatedStorage.Events

local Chat = Events.Chat

-- Main
Chat.OnServerEvent:Connect(function(Message, ID, Player)

    local function Filter(ToUserId)
	
	    local Success, Result, Error = pcall(TextService.FilterStringAsync, TextService,         Message, ID, Enum.TextFilterContext.PublicChat)
	
	    if Success then
		
		    local Filtered, Error = pcall(Result.GetChatForUserAsync, Result, ToUserId)
		
		    if Filtered then
			
			    Chat:FireAllClients(Filtered, Player.Name)
			
		    else
			
			    warn(Error)
			
		    end
		
	    elseif Error then
		
		    warn(Error)
		
	    end
		
    end

    Filter()

end)

If you could help, I would be so happy.

1 Like

Hi,

Could you provide a little more information regarding exactly what’s going wrong with the script? For example, have you used traced your algorithm to see exactly what code is running and where? Have you checked the output to see whether anything’s being spat out by the errors and warnings?

Thanks,
-Tom :slight_smile:

Well, I checked the Output and apparently, now there are no errors. But it stills doens’t work.

When I try to send the Message, it don’t work too.

Can you do an explanation easy to understand? (I’m dumb and I’m newbie here)

I think that I broke the script more than it already was…

It’s fine to be “newbie” here, this is what the forum is for. Have you used a breakpoint to see what code is actually being run?

Check out this article that will help with things like this in the future:

Hope this helps,
-Tom :slight_smile:

1 Like

Use chat service Chat
FilterStringForBroadcastAsync() might be what your looking for

1 Like

Thanks. I’ll check it :slightly_smiling_face:

1 Like

Oh yeah you should also see this:

1 Like