Filtering on admin kick reasons

Hello dev’s, I have been working on an admin panel and implemented filtering to prevent inappropriate kick reasons and to comply with Roblox TOS since these types of things need to be filtered if players are going to see the reason with the current code I have tested and the filtering works but I am wondering if this is enough or I should add fail safes etc. and if so how?

thanks

local ChatFilterService = game:GetService("TextService")

game.ReplicatedStorage.Admin.KickEvent.OnServerEvent:Connect(function(plr,targetuser, reason)
	if not table.find(admins, plr.UserId) then plr:Kick("Denied") warn(plr.Name.." Exploit Detected") return end

	local Step1 = ChatFilterService:FilterStringAsync(reason, plr.UserId) -- We get
	local Filter = Step1:GetNonChatStringForBroadcastAsync()
	
	game.Players:FindFirstChild(targetuser):Kick("Reason: "..Filter)
	warn(targetuser.." Has Been Kicked For: "..Filter)

end)


Roblox filters kick messages automatically, though…

But, using a backup incase the main one fails would be good. The easiest way to do this would probably be with xpcall.

local success, text = xpcall(function(): string
    return TextService:FilterStringAsync(reason, player.UserId):GetNonChatStringForBroadcastAsync()
end, function(err: string): string
    --manually filter out bad words
    return filtered--your manually filtered text
end)

You should check using pcall and do check if target user and reason both actually exists before applying the logic.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.