• KeyDown a nil value?
    5 replies, posted
Hey, so i'm working on a Anti-AFK addon, and im wanting to check if the player if holding down a key or not, just to make sure they don't get false-kicked. Whenever the timer gets triggered it generates a error saying that the KeyDown function is nil. The code is being run serverside. https://pastebin.com/BHxSTJQe I don't know if im just being stupid or what, if theres anyone that knows what i'm doing wrong please tell. Thanks
This is quite weird. I tested the code and it did not work as you said. But when I removed the "v:KeyDown(IN_MOVELEFT) or KeyDown(IN_MOVERIGHT)" from the code it worked fine. I think the problem is that IN_MOVELEFT and IN_MOVERIGHT does not exist because I got the same error when I wrote something random in the keydown function. Please correct me if I am wrong.
If you make the addon react on if a key is pressed down everyone can still fake being active the same way they did all the time. +forward +left in the console
You're missing a v: in front of the last KeyDown
The problem is - you forogot to add v: to your last condition so edit the code as following; timer.Create("antiafkcheckhold", 1, 0, function() for k,v in pairs(player.GetAll()) do if v:KeyDown(IN_FORWARD) or v:KeyDown(IN_BACK) or v:KeyDown(IN_MOVELEFT) or v:KeyDown(IN_MOVERIGHT) then print("hello") end end end)
Oh right, i WAS being stupid. Thanks!
Sorry, you need to Log In to post a reply to this thread.