wp_get_post_terms()
will return a WP_Error
object if the taxonomy can’t be found. So $events[0]
won’t exist if that happens.
If you’re getting this error it means that there’s no taxonomy named events
registered on your site. So you’ll need to make sure that you’ve used the correct name for the taxonomy whose terms you want to list.