If you've been having this problem, the secret thing to know is that (to NTs), it's kind of rude to mention future group plans in front of someone who isn't invited but plausibly could be, with the result that mentioning the plans often constitutes a low-stakes invitation.
This is specifically for plans where the group going is one that you could reasonably be considered part of--and that's the bit that makes it tricky! Sometimes the person speaking will think it's completely obvious whether you are or aren't part of the group, when it really isn't.
For instance, if someone at work says, "We're going to such-and-such for a drink after we get off," that's an invitation! If they say, "My family are doing such-and-such over the weekend," and you are not part of their family, that's small talk.
Phrases like, "we," "some of us," "a few of us," and so on often signal that the plans being discussed are for a loose group that you could almost certainly be part of if you wanted. The key here is the first person plural--we, us, our.
Specific names or descriptions--"My family," "Jane and I," "the gang from accounts payable"--signal a closed group that, if you were being invited to join, they'd probably be more direct about it.
The response, "Cool--have fun!" is taken as a soft no because of the implied subject of the sentence: "you/y'all/you guys have fun!" That separates the speaker (you) from the group that is going.
If you think it's probably an invitation but don't want to just assume, you can say something like, "Is there room for one more?" (The mentioning-future-plans-to-someone-who-is-not-included taboo is strong enough that, if you got it wrong, they will probably be embarrassed and take it as their error, unless they were actually trying to be an asshole.)
This phrasing gives them an easy out if they didn't mean to invite you--they can say something like, "Oh, sorry, the table's pretty full, but maybe next time!" (The second part may or may not be sincere, but if it isn't, they won't mention plans of this type to you again. Conversely, if they want to hang out with you, they might make future plans specifically for the purpose of including you. It could go either way!)
If there aren't any obvious clues, but you would be interested in going if it is an invitation, you can say something like, "Cool," or "That sounds fun," and then if they did mean to invite you, they will probably say something that clarifies the situation, like asking directly if you're going to join in, or providing logistical details--"we usually sit at the big table in the back," or, "We're taking separate cars and meeting at X"--that you would not be of any interest to someone who is not going.