I've heard there was a period in Japanese history, displayed in media such as the game Shogun Total War, where at one point the samurai were forced to fight against firearms/guns. However I cannot remember who they were fighting what the reason was or really anything about it. Is there a specific name for this period? Also are there any books or other media you would recommend, fictional or non fictional, to see and learn more about this as this topic really intrigues me. Thank you!
The era depicted in the game you referenced is called the "Sengoku jidai", the "period of (the) warring states". This covers broadly 150 years of pretty much constant civil war between several factions. As for the use of guns, I would refer you to [this thread] (https://www.reddit.com/r/AskHistorians/comments/e5ux8d/what_kind_of_weapons_did_the_samurai_during_the/). In the answers to that threat you'll find not only a brief overview of how the guns turned up in more or less common usage in Japan, but also find some quality book recommendations. In particular, u/Total_Markage lists Warriors of Medieval Japan by the always excellent Stephen Turnbull.
Now that you know the name for the period you're looking for, you might also want to check out the search function of the sub. There are tons of questions regarding this topic, and I'm sure you can find further literature there.
As for fictional works:
Shogun by James Clavell plays in the latter stages of that specific period. It's a challenging read at over 1000 pages, but quite rewarding. It does take various liberties with historical accuracy.
The classic movie Seven Samurai by Akira Kurosawa also depicts the Sengoku era (and probably several others of his movies as well, don't quote me on that though).
It'd help if you'd provide a few more details, as the game you're referencing has two separate periods with firearms.
The first takes place in what is known as the Sengoku Period, a period where the central authority of the Shogunate had declined and daimyo began to operate - and fight wars - largely independently. It was during this period that European-style matchlocks were introduced to Japan by Portuguese traders landing on the island of Tanegashima in 1542. A distinctive style of matchlock firearm going by the namesake of the island they first appeared on would rapidly proliferate through Japan in the years following. In 1575, we'd even see a devastatingly effective employment of these guns by Oda Nobunaga at the Nagashino, where gunners using these Tanegashima matchlocks were able to halt a charge by more traditional Takeda cavalry. However, while the Tanegashima would some to be a popular weapon in late Sengoku-period armies, they suffered many of the same failings of matchlocks in Europe. In Europe, this led to the development of pike-and-shot tactics, and Japan during this period would see a similar reliance on melee combatants working in conjunction with gunners.
The period I assumer you're likely referring to, however, is the Bakamatsu and Meiji Restoration. This period saw a more stark contrast between Western modernity and traditional Japanese ways of fighting. Here, the issues at hand were very complex. The short version is that the arrival of the Westerners (and the forced-open ports that came with it) caused a culture shock and instability that undermined the authority of the Tokugawa Shogunate ruling in Edo (modern Tokyo). This instability was capitalized upon by dissident elements led by men from Choshu and Satsuma in the southern end of the country to overthrow the Shogunate and "restore" the Emperor by establishing a new government with the Emperor as a largely ceremonial head of state and ministers dominated by the Choshu and Satsuma men who led the revolution.
For a very thorough look at the Bakamatsu Era and Meiji Restoration, I'd recommend checking out Samurai Revolution: The Dawn of Modern Japan Through the Eyes of the Shogun's Last Samurai by Romulus Hillsborough.