The code has so many issues with it that itâs going to take an entire essay to mention all of them, so here I go.
Firstly, the entire system is flawed, sure it kicks the person who said a blacklisted word, but it doesnât prevent the message from being sent, as @AWhale_OfATime pointed out, as the Chatted
event fires whenever the player chats in-game, meaning the message had already been sent and removing it would be difficult.
Secondly, I donât see why you had to include Anti-chatting/Group Anti-Chatting when you could use SetCoreGuiEnabled
to disable the chat for certain people, or better yet if you still want them to see the chat, create custom chat implementations, which is certainly possible, Iâm still unsure why you even added it in the first place considering this resource was originally for âBlacklistingâ words.
This script couldâve easily been replaced with chat modification modules to prevent it from being sent and, if possible with this, to kick the player if the message is rejected.
Why are there things for auto update that are still non-functional? Just include it when theyâre created, not as placeholders. And why are there 2 of each script??
Now with the general complaints out of the way, here are my complaints about the code itself
The blacklisted messages for when you are kicked has no variables to account for anti chat or group anti chat messages, theyâre just hastily placed into the first argument of Kick
, which is inconsistent with the message you get when you send a backlisted message, what wouldâve been better was the use of a dictionary to contain all the kick messages and reference the ones to be used in the script
Your group anti-chat doesnât account for more than one group, which it should since there could be others who would want to blacklist more groups if needed, maybe they have more than one grudge on a group and donât want their members to speak in their games for example
Why are you using usernames instead of UserId for allowing certain users to bypass the system? What if they change their name? They wont be whitelisted anymore, itâs practically common use to use UserId for anything to be done on a player, as they will never change, but usernames can be changed, itâs never a good idea to use usernames. Also, the way the if statements are set up makes it so even if youâre whitelisted but you say âthis is a testâ, it will still kick you since thatâs the first thing it checks. Please use a guard clause to return
if theyâre whitelisted/exempted from this check to prevent issues
Why did you give the player parameter a vague name like b
, code should be self-commenting, vague names will confuse you later on and others.
game.Players
is not really preferred to get the Players
service, itâs better to use game:GetService("Players")
especially since this is open source code to prevent the unlikely event that someoneâs Player service name is different.
Why is
elseif table.find(IgnoreBlacklistedMsgs, b.Name) then
print("Cannot kick user.")
Repeated twice in your script? and why in some of the if statements are you checking b.Chatted
, when clearly if this event was ran they did chat.
The grammatical mistakes in your comments are nitpicky to mention, but doesnât really help if you were trying to go for a professional approach
And the biggest problem I see is that it right now checks for exact equality between the filtered message, rather than just checks if a certain word has been said in the message and if it was, kick them. And the way you did it/may do it again is flawed, as for every new blacklisted word, you have to make another if statement rather than checking a table with all the blacklisted words, which is way too unoptimal, especially if someone wants to blacklist 5 or more words for example, they would have to add 5 if statements, which couldâve easily been prevented via a table for all their blacklisted words
This code has way too many flaws and care shouldâve been applied before releasing this out for future usage for others, care should always be a priority when making something if itâs going to be used by others to ensure it is easy to use and simple to understand as much as possible