Coincidentally, I just finished making my own hit detection system! There’s more to this than it seems at first, but you basically have two branches of options here:
Do hit casting on the server as well as client (easy way)
Have the client fire a remote event whenever it fires, and when the server receives the event, run through anti-exploit checks (such as fire rate, possible at all, etc), and do the cast on the server, replicating it and the hit detection to the other clients, effectively making the client cast visual only. (You can use a remote function to return to the client what parts you want it to make transparent/delete so it doesn’t see the server-sided visuals)
Lag compensation (hard way)
There are many ways you can make lag compensation, but they’re all significantly harder or than the previous method. Counter-Strike, a very popular competitive FPS multiplayer game, does this by saving player positions frequently, and rolling back their position to when the bullet was actually fired (compensating for latency, or ping). Here is a short article on their website that explains it some more: Lag compensation - Valve Developer Community
Keep in mind that this isn’t the only way to do lag compensation, and with a bit of creativity, you might find one that works best for you! The project I’m working on right now absolutely needed lag compensation due to high-velocity movement, as with the first method, bullets would show up way behind where you fired them (due to latency). If you do go ahead with this method, I suggest using the PlayerPing module, which finds player pings to terrifying accuracy (I’ve used it for my implementation).