I have been working on scripting my first gun recently. And I have got most of it working except bullet spread.
The problem I am having is bullet spread increases the closer your mouse it to the barrel of your gun.
Heres a gif to show you an example.
https://gyazo.com/3435f34daf2a3a427ad27723abdf67b5
Heres my code for the ray script.
local BulletRay = Ray.new(BarrelPosition, (Vector3.new(MousePosition.X + Random.new():NextNumber(-Spread, Spread), BarrelPosition.Y, MousePosition.Z + Random.new():NextNumber(-Spread, Spread)) - BarrelPosition).Unit
I only want spread on the X and Z axis because my game is top down.
Thank you for your time :) Have a gooood dayyyyy