Is there a more efficient way to make gun projectiles?

So I am making a game where you have bubble guns, and my current script works alright but I was wondering if there is a better way to make a gun that shoots projectiles? I currently in a localscript, cast a ray to the mouse (idk how to get direction), then it fires a remoteevent that will tell the script to create a part but add a random offset multiplied by the accuracy, then it will set the parts cframe to face the mouse position then create a bodyvelocity inside the part that makes the part travel in the direction it is facing (towards the mouse plus the offset)

I’d recommend using FastCast for this. It is a maintained module which would fit exactly what you are doing: Making a combat game with ranged weapons? FastCast may be the module for you!