Im Relatively new to scripting or developing as a whole i really liked black magic but im nowhere near the skill needed to make a game like that from the ground up however I was able to make this bare bones system with help from a friend which then I later did do it over from scratch so I understood what I was doing.
For future implementations i wanna be able to add buffers and make this a system i can use for differnet characters. Overall I want to turn this client code into a modular system
–//SERVICES//–
local Players = game:GetService(“Players”)
local InputService = game:GetService(“UserInputService”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local StarterGui = game:GetService(“StarterGui”)
local InputGui = StarterGui.InputGui
local InputLabel : TextLabel = InputGui.Container:WaitForChild(“KeystrokeLabel”)
local player : Player = game.Players.LocalPlayer
local ValidKeys = {
‘Q’,
‘E’,
‘R’,
‘Z’,
‘X’,
‘C’,
‘A’,
‘S’,
‘D’,
‘W’
}
local Keystrokes = {
‘SAX’,
‘WADQ’,
‘ZXC’,
‘DSC’
}
local Inputs = {}
local Keystroke = ‘’
local InputWindow = 0.4
local LastInput
local function ValidateKeys(Keystroke)
if not table.find(ValidKeys, Keystroke) then
warn(“Invalid Key”)
else
return true
end
end
local function UpdateInputs(Keystroke)
table.insert(Inputs, Keystroke)
print(Inputs)
end
local function CheckLastInput(Keystroke)
LastInput = os.clock()
task.delay(InputWindow, function()
if os.clock() - LastInput >= InputWindow then
Inputs = {}
end
end)
if os.clock() - LastInput <= InputWindow then
for _, v in pairs(Keystrokes) do
if table.concat(Inputs) == v then
print("Valid Keystroke")
--[[table.clear(Inputs)]]
end
end
end
end
local function DisplayKeys(input : InputObject, gpe:boolean)
if gpe then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
InputLabel.Text = " "..tostring(input.KeyCode.Name)
end
end
InputService.InputBegan:Connect(function(input: InputObject, gpe:boolean)
if gpe then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
local Keystroke = input.KeyCode.Name
if ValidateKeys(Keystroke) then
DisplayKeys(input, gpe)
UpdateInputs(Keystroke)
CheckLastInput()
end
end
end)