How to check if the player has pressed a key that is on a table?

literally the title

for index,value in Array do -- iterates through array
    if Input.KeyCode = value then -- if Input is the iterated value
        -- code
    end -- end of if statement
end -- end of for loop

use task.spawn() to prevent yielding.

If you are asking how to check if they pressed a key, use UserInputService

Have you show us what you have tried?

I guess table its something like this
keybinds = {

Then I guess just:

        for _,v in pairs(keybinds) do
                if input.KeyCode = Enum.KeyCode[v] then -- fixed not "Enum.KeyCode.v"
                       -- code

don’t tested can be wrong

if input.KeyCode = Enum.KeyCode[v] then

Here is a fix.

Thanks a lot! i have been trying for 5 hours!

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