Garry's Mod Wiki


  boolean GM:PlayerSwitchFlashlight( Player ply, boolean enabled )


Called whenever a player attempts to either turn on or off their flashlight, returning false will deny the change.

Also gets called when using Player:Flashlight.


1 Player ply
The player who attempts to change their flashlight state.
2 boolean enabled
The new state the player requested, true for on, false for off.


1 boolean
Can toggle the flashlight or not


Only allow the flashlight for admins, you can also use Player:AllowFlashlight for that.

hook.Add( "PlayerSwitchFlashlight", "BlockFlashLight", function( ply, enabled ) return ply:IsAdmin() -- Allow the player to use their flashlight if they are an admin end )