Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I made a script where if a certain word is used in a sentence, the player is kicked?

Asked by 6 years ago

Please help me make a script where if a person says a certain word in the sentence they get a warning then their kicked!

I am making a HUGE Christmas Update for my game Code Hunters called (Code Hunters: The Rise of the Codes). Now I am not an expert at scripting, but I got help on a script that I want to improve. The old script is if you just say a code like (I8U9O1K) then your kicked instead of saying (yo peeps, a code is I8U9O1K happy now?) the sentences don't work with the code! Code Hunters is a game where you search for code blocks with the code on it, you type the code on the block in the code typer and then you submit it and if it's the right code you get a reward like a slice of pizza or so. I am trying a new coding system for this update. I am making it where there's a folder in workspace called 'Codes' and I added values named 'A', 'AB' and added the codes in the values as a shorter way. I just did that because I used to have to copy and paste the code in like 8 different places, now I change the code to what the value says and it changes the code, but same reward.

local Blockers = {
    game.Workspace["The Rise of the Codes"].Codes.A.Value;
    game.Workspace["The Rise of the Codes"].Codes.AB.Value;
}

local msg = "You have been kicked from the server. Please do not say codes in the chat. You could rejoin!"

game.Players.PlayerAdded:Connect(function(newPlayer) --Use "Connect"!
    newPlayer.Chatted:Connect(function(newMessage)
        for i, v in pairs(Blockers) do
            --string.lower() comparison so cases aren't an issue
            if newMessage:lower() == v:lower() then
                newPlayer:Kick(msg) --Use "newPlayer" parameter!
            end
        end
    end)
end)

the part where is says (game.Workspace["The Rise of the Codes"].Codes.A.Value;) that is just the value of the code that I could change and it even works if I change the code.

Please help me make a script where if a person says a certain word in the sentence they get a warning then their kicked!

0
Is "string.match(newMessage, v:lower())" not what you're looking for? fredfishy 833 — 6y
0
^ string.match() and if it doesn't return nil then kick them Vulkarin 581 — 6y

Answer this question