I’m trying to make another shotgun spread, and I’ve fixed the spreading directions, however sometimes the shotgun fires in a straight line. This is because of a math.random duplicate This is the output
Part 7.68883085, 3.25965953, 11.7818241 (x2)
Part 7.68883085, 3.25965977, 11.7818241 (x2)
nil 22.2675266, 16.2970352, -36.9516144
Part 6.14408875, 4.21448708, 8.80914402 (x9)
This could be because of the nature of how math.random() works. I suggest you try using Random, specifically Random:NextNumber(), instead, and seeing if that makes a difference.
Here’s what I did now: Also the division is for the spread so that it doesn’t go all over the place
local x = Random:NextNumber(-spread,spread)/15
local y = Random:NextNumber(-spread,spread)/19
local dir = CFrame.new(mainpos, mousehit) * CFrame.Angles(x,y,0)
When I use Random it says: attempt to call a nil value
what do I do?