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

Filtering String Async not working? instead saying 2nd argument is missing??

Asked by 3 years ago
Edited by EzraNehemiah_TF2 3 years ago

I made a script that prevents scammers from scamming other players, I'm going to add more filter stuff in the table soon.

It's saying that the 2nd argument is missing on the last line aka. :FilterStringAsync()

local txtservice = game:GetService("TextService")

local filterWhiteboard = {"robux.gg", "free robux"}

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        for _, v in ipairs(filterWhiteboard) do
            if string.lower(msg) == v then

                txtservice:FilterStringAsync(msg)
            end
        end
    end)
end)
0
txtservice:FilterStringAsync(msg, player)? mixgingengerina10 223 — 3y
0
ohh CaIcuIati0n 246 — 3y
0
I'll try CaIcuIati0n 246 — 3y
0
The problem is your code is seeing if they say "robux.gg" or "free robux" exactly. If they add a capital letter or a period at the end, the code isn't going to work because it isn't exact. Use string.lower or string.upper with string.find to see if there is a message saying "free robux" anywhere in their code. When you call FilterStringAsync, it returns an instance. EzraNehemiah_TF2 3552 — 3y
View all comments (7 more)
0
not working CaIcuIati0n 246 — 3y
0
@lorddragonzord so how do i filter the message ?? CaIcuIati0n 246 — 3y
0
Don't use FilterStringAsync at all, basically. I also wouldn't kick anyone who says "robux.gg" immediately, perhaps give them a warning of some sort so that real players don't get kicked for saying it as a joke, for example. EzraNehemiah_TF2 3552 — 3y
0
Like I said earlier. Use a combination of string.lower/string.upper and string.find. Look here for more information: https://developer.roblox.com/en-us/api-reference/lua-docs/string EzraNehemiah_TF2 3552 — 3y
0
i dont want to kick them, but replace the message with hashtags. CaIcuIati0n 246 — 3y
0
Doesn't roblox already filter the messages before it gets sent :/ mixgingengerina10 223 — 3y
0
The problem with roblox's filtering is that it doesn't filter out robux.gg or free robux at all. Even to those who are less than 13 years of age. Your best bet is to make your own chat gui and use string.gsub to censor out any blacklisted words. EzraNehemiah_TF2 3552 — 3y

2 answers

Log in to vote
1
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

FilterStringAsync has 3 parameters, but you only added 1.


1) StringToFilter

local textService = game:GetService("TextService")

local message = "Hello World!" -- the string to filter

textService:FilterStringAsync(message) 

2) FromUserId

local textService = game:GetService("TextService")

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        textService:FilterStringAsync(message,player.UserId)
    end)
end)

3) TextContext

(optional)

local textService = game:GetService("TextService")

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        textService:FilterStringAsync(message,player.UserId,Enum.TextFilterContext.PublicChat)
    end)
end)

Edited code:

local txtservice = game:GetService("TextService")

local filterWhiteboard = {"robux.gg", "free robux"}

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        for _, v in ipairs(filterWhiteboard) do
            if string.lower(msg) == v then

                txtservice:FilterStringAsync(msg, player.UserId)
            end
        end
    end)
end)

Also, your code is detecting if their chat is only robux.gg or free Robux, so use string.find.

local txtservice = game:GetService("TextService")

local filterWhiteboard = {"robux.gg", "free robux"}

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        for _, v in ipairs(filterWhiteboard) do
           if string.find((string.lower(msg), v) then
                txtservice:FilterStringAsync(msg, player.UserId)
            end
        end
    end)
end)
Ad
Log in to vote
1
Answered by 3 years ago

FilterStringAsync has 3 parameters: stringToFilter: the strings you want to filter.

playerFrom: the player that sent the text.

playerTo: (This one I got from devforum wiki) The intended recipient of the provided text; use the author if the text is persistent.

So basically, you need to enter the player in the playerFrom argument, just like so:

-- filterstringasync is deprecated in local scripts, so we doing it in a server script
local txtservice = game:GetService("TextService")

local filterWhiteboard = {"robux.gg", "free robux"}

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        for _, v in ipairs(filterWhiteboard) do
            if string.lower(msg) == v then

                txtservice:FilterStringAsync(msg,player) -- added the player argument from PlayerAdded
            end
        end
    end)
end)

I hope this answered your question!

Answer this question