Skip to main content

IsButtonBeingPressed

Description​

Use this if you want things to only happen once per button press. Check here for more info about the button ID and the controller ID.

function IsButtonBeingPressed(button, controller) --[[ ... ]] end

Parameters​

  • button: integer - The button ID to check.
  • controller: integer - The controller index.

Return Values​

  • state: boolean - Returns true if the button was just pressed this frame, false otherwise.

Example​

Creates Russell ped in front of the player and sets his HP to 30.

if IsButtonBeingPressed(0, 0) then
local x, y, z = PedGetOffsetInWorldCoords(gPlayer, 0, 1, 0)
local Russell = PedCreateXYZ(75, x, y, z)
PedSetHealth(Russell, 30)
end

See Also​