Cheat codes like

You could do something like this:

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

local joinedCodeString = ""
local lastCodeUpdate = nil
local player = Players.LocalPlayer

local cheatCodeTable = {
	["TESTCODE"] = function()
		print(player.Name, "executed TESTCODE")
	end,
	
	["ANOTHERCODE"] = function()
		print(player.Name, "executed ANOTHERCODE")
	end,
}

UserInputService.InputBegan:Connect(function(input: InputObject)
	if input.UserInputType ~= Enum.UserInputType.Keyboard then
		return
	end
	
	if not input.KeyCode then
		return
	end
	
	if input.KeyCode.Value < 97 or input.KeyCode.Value > 122 then -- Ignore characters that are not alphabets
		return
	end
	
	if lastCodeUpdate and (os.clock() - lastCodeUpdate) >= 2.5 then -- Time before cheat code resets
		joinedCodeString = ""
		lastCodeUpdate = nil
		return
	end

	joinedCodeString ..= input.KeyCode.Name
	lastCodeUpdate = os.clock()
	
	if not cheatCodeTable[joinedCodeString] then
		return
	end
	
	cheatCodeTable[joinedCodeString]()
	
	joinedCodeString = ""
	lastCodeUpdate = nil
end)
2 Likes