Im adding a shotgun mode to my guns and heres one problem: I want to make the shotgun spread depending how long the range is and it looks too big when you shoot somewhere closer to you. heres the code
for v = 1,(Config.ShotgunMode and Config.BulletsPerShot or 1) do
local ShotgunSpreadX = Config.ShotgunMode and math.random(-5,5) or 0
local ShotgunSpreadY = Config.ShotgunMode and math.random(-5,5) or 0
local ShotgunSpreadZ = Config.ShotgunMode and math.random(-5,5) or 0
local BulletRay = Ray.new(Tool.Handle.BulletStart.WorldCFrame.p,(Mouse.Hit.p + Vector3.new(ShotgunSpreadX,ShotgunSpreadY,ShotgunSpreadZ)-Tool.Handle.BulletStart.WorldCFrame.p).unit*Config.Range)
--Theres more code; I dont want to show it

2 comments
Thanks but it could been Vector3.new(distance,distance,distance)
yeah, this is just including the randomization aspect of your original post. you can change it to work however you want, this is just an example