Code
cmds = {}
cmds = {
Commands = {
["kick"] = {2,function(Admin,arg) --Rank, Arguments
--[[print("Running, Args below:")
print(arg)]]
-- arg2 is the player being kicked
-- arg3 is the reason
if not Admin:IsInGroup(GroupID) then return end
if Admin:GetRankInGroup(GroupID) < LevelOfRestriction.Moderator then warn(Admin.Name.. " has insufficient permission to perform a kick!") return end
CheckConditions(Admin,2)
if type(arg[2]) ~= "string" then return end
if type(arg[3]) ~= "string" then return end
local String = arg[3]
local newString = TextResultMessage(Admin,String)
if newString == false or newString == nil then
local Retries = 0
repeat
newString = TextResultMessage(Admin,String)
task.wait(0.1)
Retries += 1
until newString ~= false and newString ~= nil or Retries >= 5
print(newString)
if newString == false or newString == nil then
warn("Filtered Text!")
newString = "No reason given (Or the text has not been filtered correctly)."
end
end
local function KickPlayer(Player)
Player = PlayerService:FindFirstChild(Player)
Player:Kick("You've been kicked by ".. Admin.Name.. "! Reason: ".. String)
end
if arg[2] and arg[2] ~= "all" and arg[2] ~= "me" and arg[2] ~= "others" then
KickPlayer(arg[2])
elseif arg[2] == "all" then
for Index, ReturnedPlayers in pairs (PlayerService:GetPlayers()) do
task.spawn(KickPlayer,ReturnedPlayers.Name)
end
elseif arg[2] == "others" then
for Index, ReturnedPlayers in pairs (PlayerService:GetPlayers()) do
if ReturnedPlayers.Name ~= Admin.Name then
task.spawn(KickPlayer,ReturnedPlayers.Name)
end
end
elseif arg[2] == "me" then
KickPlayer(Admin.Name)
end
end,};
--..
}
}
--Function for filtering Text
function TextResultMessage(Admin,String)
local Result = nil
local Success, Errorm = pcall(function()
Result = TextService:FilterStringAsync(String,Admin.UserId,Enum.TextFilterContext.PublicChat):GetChatForUserAsync(Admin.UserId)
end)
return Result
end
Keep in mind I have tested both in-game and on studio. For context, I’m getting strings from a table (even without a table, FilterStringAsync doesn’t filter the message for some reason). This is part of a custom-made Admin Commands module for my game.
The real problem starts at FilterStringAsync. Everytime I say something that is guaranteed to be flagged by Roblox’s Filter, the message goes through just fine, despite writing the code how it should be according to the Roblox documentation when it comes to filtering text messages. Although not shown, I have the TextService service variable on the very top of my ModuleScript and a system to separate strings, passing them as tables. I’ve been testing for a hour on trying to get FilterStringAsync to work, but the text is not filtering as it should be.
I’m at a loss of solutions. The method for activating the “Kick” command is via the Roblox Chat or A GUI console for secrecy. I don’t have any clue on what the problem is (besides the text not filtering fast enough/I’m using the wrong service.) If anyone would like to help, please do so! Thank you.