Camera shakes until I hit something

So I did a camera shake function from youtube but whenever I play the game it just starts shaking until I hit a game object thus invoke the function.