Raycasting Gun Spread

To add spread to a raycasting weapon, simply add a math.random() on the finishing position.

local SPREAD = 1000 -- set some value for it
local spreadPosition = Vector3.new(
    FirePoint.WorldCFrame.Position.X + math.random(-SPREAD, SPREAD)/1000,
    FirePoint.WorldCFrame.Position.Y + math.random(-SPREAD, SPREAD)/1000,
    FirePoint.WorldCFrame.Position.Z + math.random(-SPREAD, SPREAD)/1000
)

I reckon there was a better method.


Looks like parent argument of Instance.new() is here again. Do not use it.

6 Likes