So, I've written a bullet spread script, but there's a problem with it. No matter the range, the bullet will offset the same amount, making it possible to miss at point blank which obviously is an issue.
Here's my script, any ideas how to fix it?
local xOff = math.random(-spread * 100, spread * 100)
xOff = xOff/100
local yOff = math.random(-spread * 100, spread * 100)
yOff = yOff/100
local zOff = math.random(-spread * 100, spread * 100)
zOff = zOff/100
local NewPos = mouse + Vector3.new(xOff, yOff, zOff)
local ray = Ray.new(tool.firePart.CFrame.p, (NewPos - tool.firePart.CFrame.p).unit*300)
local part, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList, false, true)

2 comments
Hm. That's what I thought of doing, but say I aimed for the edge of a wall, and the spread made it not hit the wall. Wouldn't the magnitude be the magnitude of the wall?
You should use rays for this; otherwise, your script won't work one way or another. The hit position is nothing but a direction for them, so they'll continue past it.