Garry's Mod Wiki

Entity:NextThink

  Entity:NextThink( number timestamp )

Description

Controls when, relative to CurTime, the Entity will next run its Think function.

For Scripted Entities, this is the ENTITY:Think function.
For engine Entities, this is an internal function whose behavior will depend on the specific Entity type.

For a Client-side equivalent, see Entity:SetNextClientThink.

This does not work with SWEPs or Nextbots.

Issue Tracker: 3269

Arguments

1 number timestamp
The timestamp, relative to CurTime, when the next think should occur.

Example

Repeatedly prints "Hello, World!" in console with a 1 second delay between each repetition.

function ENT:Think() print("Hello, World!") self:NextThink( CurTime() + 1 ) return true -- Note: You need to return true to override the default next think time end
Output:
Hello, World! Hello, World! Hello, World! Hello, World! ...