Help with Keypressed/KeyDown

I’ve tried this with :KeyPressed and using IN_FORWARD, not really sure whats wrong.



	Reversal = function(pl)

	if( pl.KeyDown( 8 ) ) then
      print( "You pressed the forward key!" )
		end
	end


thanks for any help =D

It’s pl**:KeyDown() not pl.**KeyDown()

Sorry that was a typo, I rewrote that real quick for this thread. I had originally tried that, along with (IN_FORWARD) instead of (8)

Post the whole code.

Edit: wrong thread im dum mark me dum D:

Here is the short and sweet version:

sv_rtd.lua



dice = {}
dice.outcomes = { 

	Kill = function(pl) 
 		plname = pl:Nick() 
		diceMSG = " has been black balled, Better luck next time!"
		OutcomeMsg(pl)
		
		pl:Kill()
	end,
	
	Reversal = function(pl)
		plname = pl:Nick() 
		diceMSG = " got the old Switch a Roo!!"
		OutcomeMsg(pl)
	if( pl:KeyPressed( IN_FORWARD ) ) then
      print( "You pressed the forward key!" )
		end
	end
	
}


At the moment when the function is called, the key isn’t pressed. That function won’t be called every time forward key is pressed, that’s not how it works. If you really need to detect it with that function, you’ll have to use a Think hook.

But judging from what you are trying to do, you might want to look into GM:CreateMove and GM:Move hooks.

again wrong thread im dumb sorry

Awww man I’m an idiot I should have known that. Could I do it with timers as well or would that be frowned upon?

Also thanks for the help, you always save that day =D

You’d miss some key presses with a timer. And a 0 delay infinite timer is a bad idea. So it’s either a Think hook or GM:CreateMove and GM:Move hooks, which is what you gotta use for reversing movement.

Ok, thanks for the info boss!

Thanks again RobotBoy!!