How can I create A kick script when things are typed in chat

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am making A script that kicks people when they say"bad words"n o practice scrtipting.

  2. What is the issue? I keep getting an error in the output which changes depending on what I do with the code.

  3. What solutions have you tried so far? I have tried removing local from the variables and removing the equals sign depending on which error is being displayed.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This script would be found in game.workspace.antiBadWordScript

local warning = 0
function onPlayerChatted(player, message)
if message == "noob"  then
local warning = local warning + 1		
end
if 
local warning 1> then
	player:kick("Hi!")
end
function onPlayerEntered(player)
wait(1)
player.Chatted:connect(function (message) onPlayerChatted(player, message) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)

The script does not work but does if you remove the warning variable and kick instantly it does.
The output error is:
22:01:56.055 - Workspace.Anti Bad Word Script:4: Expected identifier when parsing expression, got ‘local’]
if I remove local the error changes to:
22:05:06.116 - Workspace.Anti Bad Word Script:7: Expected identifier when parsing expression, got ‘local’
if I remove that:
22:05:36.313 - Workspace.Anti Bad Word Script:7: Expected ‘then’ when parsing if statement, got ‘1’

Since you already localized and defined the variable warning, dont add local before it every single time you reference it.

4 Likes

I have done that but the their are still the next errors.

Lots of issues in your script.

After you defined local warning = 0, you don’t continue to use local when changing it.
You also tried to use “local” for conditional statements which doesn’t make sense. You should say “if” not “local.” Your script also is using some deprecated methods. Here is a fixed version of your script:

local warning = 0
game.Players.PlayerAdded:Connect(function(player)
 player.Chatted:Connect(function(msg)
  if msg == "noob" then
   warning = warning + 1
  end
  if warning > 1 then
   player:Kick("Hi!")
  end
 end)
end)
3 Likes

It appears you haven’t since your topic still has those errors. Mind replying again with your updated code?

The subsequent errors were me doing 1> instead of > 1 and using equals in the wrong place.
Just my bad formatting :laughing: