Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to check if a message is filtered?

Asked by 7 years ago

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?

0
Take the original message, filter it, and if they are different, then it was filtered. TheHospitalDev 1134 — 7y
0
Wow I was not thinking.. Thank you. Thundermaker300 554 — 7y

2 answers

Log in to vote
3
Answered by 7 years ago

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,

local function compare(this,toThis) --Define the function
    if this:lower() == toThis:lower() then --If the two strings are exact, meaning unfiltered.
        return true --Return true
    else
        return false --Return False
    end
end

local unFiltered = "Hi guis il ieme me"
local filtered = game:GetService("Chat"):FilterStringForBroadcast(unFiltered,game.Players.LocalPlayer) --Filter the text

if compare(filtered,unFiltered) then --Call the function, which returns true or false 
    print("NOT FILTERED!")
end
0
Thanks! Thundermaker300 554 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
local player=game.Players.LocalPlayer
local success,message=pcall(function()
      filtered=game:GetService("Chat"):FilterStringForBroadcast(text, player)
end)
if success then
      print("Successfully filtered message") else print("Failed to filter message."..message)
end
0
I don't think that's what he asked for. I think he was checking if a text was filtered or not, not if it worked or not. TheHospitalDev 1134 — 7y
0
I was looking for whether or not a message was filtered. Thundermaker300 554 — 7y
0
That script filters a text and it will check if it was filtered or not. If it was filtered then "Success" will return true else it will return false and provide the error message Gomlsauresrex -12 — 7y

Answer this question