Memory Game with keypad

Hi there, I’ve been trying to make a memory game using a keypad. What I mean is, the keypad will tell you the code, and you will have to memorize it to get it, and then you have to repeat what it does: if they click it as the keypad says, the door opens; if you get it wrong, the buttons will fade to red, and you will have to redo the pattern.

Basically, something like this; Start Reactor - The Skeld | Among Us - YouTube

Tried to find it on devforum and tried scripting it myself, but don’t know how to achieve this.

any ideas?

UserInputService - if you’re trying to do it with a numpad, otherwise use guis and research that

I am going to introduce a far simpler example here, so you can get how is that supposed to work, but idea is simple. All you have to do is keep track of player’s input and check if the answer fits to the index value.
Example:

local Code = {3,2,6,6,7}
local PlayerInput = {3,2,6,6,7} --expected output would be true
local Output = true

for i = 1,#Code do
    Output = Code[i] == PlayerInput[i] --check if player's input is correct
    if not Output then
       break
    end
end

return Output

Alright, very straight forward! but though that isn’t the effect im looking for, srry.

that’s the internal how you would verify if players click the same buttons as the computer does.

keep track of what the cpu made, then keep track of the current player’s inputs, once the player’s input count reaches the count of cpu digits you can easily check if the player is right

as for detecting input in a numpad I would suggest a lookup dictionary like this

local UIS = game:GetService("UserInputService")
local Lookup = {
  [Enum.KeyCode.Num1] = 1;
  [Enum.KeyCode.Num2] = 2;
  --etc
}

UIS.InputBegan:Connect(function(Input)
  local Value = Lookup[Input.KeyCode]
  --value is the number that corresponds to the numpad number they pressed
  if Value then
    ApplyInput(Value)--run a function to apply numpad input here
  end
end)
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.