FilterStringAsync has 3 parameters, but you only added 1.
- StringToFilter
local textService = game:GetService("TextService")
local message = "Hello World!"
textService:FilterStringAsync(message)
- FromUserId
local textService = game:GetService("TextService")
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
textService:FilterStringAsync(message,player.UserId)
end)
end)
- 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)
11 comments
txtservice:FilterStringAsync(msg, player)?
ohh
I'll try
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.
not working
@lorddragonzord so how do i filter the message ??
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.
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
i dont want to kick them, but replace the message with hashtags.
Doesn't roblox already filter the messages before it gets sent :/
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.