Posts: 723
Threads: 366
Joined: Jun 2016
Hi,
How to check if player is holding a key, for ex spectating player, with a or d and as long he hold key will be changing spectating player
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
Figure out the interval you want before changing to the next player. Half a second will do probably. Perhaps a bit less. In OnPlayerKeyStateChange when the key is first PRESSED set a repeating timer and assign it to a variable. When the key is RELEASED use the variable to kill the timer. In the timer itself do the spectate stuff.
Worth noting though that directional keys (WASD) do not trigger OnPlayerKeyStateChange so you will have to resort to OnPlayerUpdate if you want to reliably detect those.