I'm making a shout system, that uses 100 in game coins to shout. The shout works handy dandy, However, I do not want the shout to send if the message is filtered. I looked on the wiki to see if there was a return type under the filter method, but there doesn't appear to be any. Can someone please tell me how to do this?
Like I said in my comment, you could just check if the filtered text matches the unfiltered text, if it does, it was not filtered!
A simple function to compare this,
01 | local function compare(this,toThis) --Define the function |
02 | if this:lower() = = toThis:lower() then --If the two strings are exact, meaning unfiltered. |
03 | return true --Return true |
04 | else |
05 | return false --Return False |
06 | end |
07 | end |
08 |
09 | local unFiltered = "Hi guis il ieme me" |
10 | local filtered = game:GetService( "Chat" ):FilterStringForBroadcast(unFiltered,game.Players.LocalPlayer) --Filter the text |
11 |
12 | if compare(filtered,unFiltered) then --Call the function, which returns true or false |
13 | print ( "NOT FILTERED!" ) |
14 | end |
1 | local player = game.Players.LocalPlayer |
2 | local success,message = pcall ( function () |
3 | filtered = game:GetService( "Chat" ):FilterStringForBroadcast(text, player) |
4 | end ) |
5 | if success then |
6 | print ( "Successfully filtered message" ) else print ( "Failed to filter message." ..message) |
7 | end |