You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
so I got the script from this topic. If player sends a message, kick the same player and I modify it so if players say multiple words that are harmful to other players or the game then they will get kicked out of the game. I tried both method table.find and string.find, the script is in serverscriptservice.
What is the issue? Include screenshots / videos if possible!
but however, when I say the trigger word in chat it gives me this error…
ServerScriptService.Anti-EDetection:9: missing argument #1 to ‘lower’ (string expected)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have already tried the solution on the link I shown above. But it doesn’t work and it gives me an error I also try finding the error for my script still couldn’t find it.
I’d be appreciated if you could help me with this…
I’m actually new to scripting and I am curious and I want to learn how things work behind the coding process and what do these do.
local Players = game:GetService('Players')
local TriggerMessage = {
"i hate this game",
"this game is so bad"
}
function playerAdded(p)
p.Chatted:Connect(function(TriggerMessage)
if TriggerMessage.lower() == string.find(Players, TriggerMessage) then
p:Kick('Congratulations for getting a banana!')
end
end)
end
for _, player in next, Players:GetPlayers() do
playerAdded(player)
end
Players.PlayerAdded:Connect(playerAdded)
you are doing a couple things wrong. first you overwrite the table here
p.Chatted:Connect(function(TriggerMessage)
the table is also called TriggerMessage, so you can’t acces the table anymore. You should rename it to msg or message like this:
p.Chatted:Connect(function(message)
secondly, you use a dot instead of a colon. You have to use a colon if you want to lower a string like that.
message:lower()
or you can do
string.lower(message)
both do the same thing. Now you wrote the if statement wrong. If you do this with all the correction, you get this:
function playerAdded(p)
p.Chatted:Connect(function(message)
if message:lower() == string.find(Players, TriggerMessage) then
p:Kick('Congratulations for getting a banana!')
end
end)
end
but you have to find the lowered message in the table, not in the Players Service. So you have to do this:
if table.find(TriggerMessage, message:lower()) then
p:Kick('Congratulations for getting a banana!')
end
what you are doing here, is you are trying to find the lowered message in the TriggerMessage table. The final script should be this:
function playerAdded(p)
p.Chatted:Connect(function(message)
if table.find(TriggerMessage, message:lower()) then
p:Kick('Congratulations for getting a banana!')
end
end)
end
hmm… am not being kicked out somehow when being said the triggerMessage in the chat
Updated Code:
local Players = game:GetService("Players")
local TriggerMessage = {
"you are so bad"
}
function PlayerAdded(p)
p.Chatted:Connect(function(message)
if table.find(TriggerMessage, message:lower()) then
p:Kick('Congratulations for getting a banana!')
end
end)
end
you still have to connect the function to playeradded, so you script should be:
local Players = game:GetService('Players')
local TriggerMessage = {
"i hate this game",
"this game is so bad"
}
function playerAdded(p)
p.Chatted:Connect(function(message)
if table.find(TriggerMessage, message:lower()) then
p:Kick('Congratulations for getting a banana!')
end
end)
end
for _, player in next, Players:GetPlayers() do
playerAdded(player)
end
Players.PlayerAdded:Connect(playerAdded)
you also have to type in the exact message as in the table, otherwise it won’t work.