Player.Crouching

From GMod Wiki

Jump to: navigation, search
Function
Syntax Player:Crouching( )
Description:
Returns true if the player is crouching.
Returns: Boolean
In Object: Player
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.Crouching]Player.Crouching [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionWill kill the player if he crouches (See Additional Notes).
Used onNewerServer.png
Code
 for _, ply in pairs(player.GetAll()) do
	if( ply:Crouching() ) then
		ply:Kill()
	end
 end
OutputPlayer dies if he crouches.


DescriptionThis is an alternative to the crouching method for use on the client. This is probably what you're looking for.
Used onNewerShared.png
Code
local ducking = false
local ground = self.Owner:GetGroundEntity()
if self.Owner:KeyDown(IN_DUCK) and (IsValid(ground) or ground:IsWorld()) then
	ducking = true
end
OutputThe variable "ducking" is set to true if the player is crouched on something, false otherwise.


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox