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)
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)
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!