• Question about input.IsKeyDown
    2 replies, posted
Hey, I am fairly new to lua and have a problem with the input.IsKeyDown() function. No matter how I use it Ex: [CODE] hook.Add( "Think", "keypress_test", function() if input.IsKeyDown( KEY_SPACE ) then print("You pressed space") end end ) [/CODE] I always get the same error: [ERROR] lua/test.lua:2: attempt to index global 'input' (a nil value) 1. v - lua/test.lua:2 2. unknown - lua/includes/modules/hook.lua:84 I understand what this means, it simply states that "input" is not defined, which doesn't make any sense... I just haven't seemed to figure this out, or see anyone with the same problem. Thanks if you can help! Again, I know this is simple stuff, I literally started programming in lua today :p
From seeing lua/test.lua I can assume you have this open in a server side file. That code works client side. Create yourself an easy workspace. Create a base gamemode, create init.lua, cl_init.lua and shared.lua. Look it up online how to do this correctly, then put that code in cl_init.lua your client side file.
I've tried running it client side before, but apparently with me being too stupid to think to restart the server it didn't work. I restarted the game, ran the code client side and it worked great. Thanks for the help.
Sorry, you need to Log In to post a reply to this thread.