Garry's Mod Wiki

Entity:SetParent

  Entity:SetParent( Entity parent = NULL, number attachmentOrBoneId = -1 )

Description

Sets the parent of this entity, making it move with its parent. This will make the child entity non solid, nothing can interact with them, including traces.

This does not work on the world.
This can cause undefined physics behavior when used on entities that don't support parenting. See the Valve developer wiki for more information.

Arguments

1 Entity parent = NULL
The entity to parent to. Setting this to nil will clear the parent.
2 number attachmentOrBoneId = -1
The attachment or bone id to use when parenting. Defaults to -1 or whatever the parent had set previously.

Use Entity:AddEffects( EF_FOLLOWBONE ) to treat this argument as a Bone ID instead of an Attachment ID. Similar to Entity:FollowBone.

You must call Entity:SetMoveType( MOVETYPE_NONE ) on the child for this argument to have any effect!