I would like to know the code or where to get it so people can only use a and d keys for my 2D Game.
Why not just use UserInputService?
They are very simple.
Do this in a local script.
-- If working with the player local player = game.Players.LocalPlayer -- If you want to receive mouse input local mouse = player:GetMouse() -- If you are working with the player's character local char = player.Character -- Crucial line of code when working with the character repeat wait() until player.Character -- Store User Input Service in a variable local UIS = game:GetService("UserInputService") -- Handle user input UIS.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.A then -- if user presses "A" -- Do things when "A" is pressed elseif input.KeyCode == Enum.KeyCode.D -- if user presses "D" -- Do things while "D" is pressed end end)
Keep in mind that if you would like to detect when user input has ended you will need to use the InputEnded event. If you are using loops then you will need bool values to detect when input has ended and stop the loop.
Note: I wrote this code directly in the browser. Don't be surprised if there are errors.