Hey there, so I’ve tried to use bullet spread before but it doesn’t really work as I intend it to.

Function

``````function spreadBullets(v)
return Vector3.new(math.random(-v, v), math.random(-v, v), math.random(-v, v) / 100)
end
``````

There are two main questions I have:

1. How would I make a spread function where the spread gradually gets worse over time as you shoot? (aka Bullet Bloom)
2. Whenever I input a value less than 1 (ie. .9), there’s no more spread and it comes out as a straight line. What’s the reason behind this?

2. math.random only returns whole numbers if given arguments

Thanks! I’ll tweak with my spread shenanigans and see what I can do.

You can fix the math.random issue by just multiplying the numbers by 10 and dividing the result by 10.

1 Like

Don’t you mean multiplying the range of numbers by 10 (if they need the value of v between 0 and 2, make it 0 and 20), then dividing the result of the math.random(v) by 10?

nooooo please just use `r = Random.new(); r:NextNumber(min, max)` xD

Have a variable in your shooting-handling-code that gets bigger every time a shot is fired and gradually decreases (every Stepped or Heartbeat or w/e). E.g.

``````local spread = 0
local SPREAD_MULTIPLIER = 1 --no idea, tune this

end

function fire()
--shooting stuff
end