Code:--[[ Simple Lua script to detect when a key or remote button (that repeats) has been held down for > x seconds. The key must repeat at least every 500 milliseconds or the code will assume the key was released and then start over. Replace the 4 in the script below to any time period desired. by Michael Cumming --]] t = clock () KeyDown = KeyDown or t KeyLastEvent = KeyLastEvent or KeyDown if t - KeyLastEvent > 0.5 then KeyDown = t end KeyLastEvent = t if t - KeyDown > 4 then TriggerEvent ("KeyHeld4Sec",18) KeyDown = nil end


Reply With Quote