This script should fire when a variety of keys (which are listed in the script) are pressed, given that the "control" value is true and a tank with the player's name was able to be found. If the key being pressed is not of the given keys, it prints "false key." However, when I press a key that is of the given bunch, it still prints false key - regardless of any key I press, it prints false key. Why is this?
local UserInputService = game:GetService("UserInputService")
player = game.Players.LocalPlayer
control = player:WaitForChild("Controlling", 120)
local function KeyDown(input, gameProcessed)
if control.Value == true then --The control value, when set to true, will switch the player's control from his character to the tank. (That is not in this script, I'm just explaining for what control is for)
local findTank = game.Workspace.Tanks:FindFirstChild(player.Name)
if findTank then --Find the tank that belongs to the player
if input.UserInputType == Enum.UserInputType.Keyboard then --Only if it's a keyboard input.
print("key pressed")
-- w = 119, a = 97, s = 115, d = 100, q = 113, e = 101, r = 114, f = 102
local keys = {119, 97, 115, 100, 113, 101, 114, 102}
local properKey = nil
for i, v in pairs(keys) do
if input.KeyCode == v then
properKey = v
print(v.. " pressed") --If the key is of the given list,
break
end
end
if properKey ~= nil then
--Stuff happens
else
print("false key")
end
end
else
control.Value = false --This shouldn't be set to true if there's no tank!
end
end
end
UserInputService.InputBegan:connect(KeyDown)
Any and all help is highly appreciated!

5 comments
In the table, try using Enum.KeyCode.[insert key here]. That may work.
It threw an error.
This is what I typed in (short version to save space) local keys = {Enum.KeyCode.[119], Enum.KeyCode.[97], Enum.KeyCode.[113], Enum.KeyCode.[101]}
Stop indexing Enum with numbers. Also looping through Enum is extremely inefficient. Like Chip said, simply type if input.KeyCode == Enum.KeyCode.X (for example)
Cabbler, this worked; you have my undying gratitude :D