Garry's Mod Wiki

type

  string type( any var )

Description

Returns a string representing the name of the type of the passed object.

This will return table if the input is Color, consider using IsColor in that case.

Arguments

1 any var
The object to get the type of.

Returns

1 string
The name of the object's type.

Example

Print the name of a few types.

print( type( 2 ) ) print( type( "hai" ) ) print( type( {} ) ) print( type( Color( 1, 1, 1 ) ) )
Output:
number string table table

Example

Returns no value if called with 0 arguments/parameters.

print( type() )
Output: no value

Example

A list of code showing how you can use the type function in replacement with any of the is* functions. (example being istable, isentity, etc.)

print( type( LocalPlayer() ) ) print( type( Vector() ) ) print( type( Angle() ) ) print( type( Entity( num ) ) ) -- num is the EntIndex for the entity print( type( vgui.Create( "DFrame" ) ) )
Output:
Player Vector Angle Entity Panel