How to make a Konami code easter egg

Anyone is allowed to use this code.

This will show you (sample code) on how to make a Konami code input system (for easter eggs and other cool stuff)

local keySequence = {}

local desiredOrder = {
	'Enum.KeyCode.Unknown', -- Required for bug purposes, regardless of processed
	'Enum.KeyCode.Up',
	'Enum.KeyCode.Up',
	'Enum.KeyCode.Down',
	'Enum.KeyCode.Down',
	'Enum.KeyCode.Left',
	'Enum.KeyCode.Right',
	'Enum.KeyCode.Left',
	'Enum.KeyCode.Right',
	'Enum.KeyCode.B',
	'Enum.KeyCode.A',
	'Enum.KeyCode.Return',
}

function listenForKeys(input)
	local output = tostring(input.KeyCode)
	local counter = #keySequence + 1
	
	table.insert(keySequence, output)
	
	if #keySequence > #desiredOrder then
		table.remove(keySequence, 1)
	end
	
	if counter == 14 then
		if table.concat(keySequence) == table.concat(desiredOrder) then
			print('Konami code entered')

			keySequence = {}
		end
	end
end

game:GetService('UserInputService').InputBegan:Connect(listenForKeys)
6 Likes