How to make a fired projectile stick in things?

How do you make, say an arrow, stick in something?

Uh there was a harppon coding in gmod.org I saw once could be good way to explain it.