I am making a game 'Code Hunters II' opening 7/21/17 and it is a code game of course. I am trying to make a script where if a player says a code out loud they are kicked from the server. Well, um... this isn't like working so please help me!

When I did game.Players.LocalPlayer:Remove() the player was gone, but was still able to chat. HELP!

local wordList = {"Code Hunter"}

game:GetService("Players").PlayerAdded:connect(function(newPlayer)
	newPlayer.Chatted:connect(function(newMessage)
		for index, value in pairs(wordList) do
			if string.match(string.lower(newMessage), string.lower(value)) then
				game.Players.LocalPlayer:Kick("Sorry, you have been kicked from the server. Please do NOT spoil the codes or ruin the other robloxians experience. You are not banned so you could rejoin.")
			end
		end
	end)
end)

1 comment

0

This shouldn't be a LocalScript, and if it isn't then you shouldn't be using LocalPlayer. Use a ServerScript and use the newPlayer variable you set up to kick the player.