So, what I'm wondering is how I can make the end of the ray (goes to mouse position) offset randomly, so when the gun fires, the ray will have a "spread", similar to actual guns. I already know how to use math.random, but I do not know where, and how to add the offset to the end of the ray.
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 2048)
local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
local beam = Instance.new("Part", workspace)
beam.BrickColor = player.TeamColor
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 0
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
local distance = (tool.Handle.CFrame.p - position).magnitude
beam.Size = Vector3.new(0.1, 0.1, distance)
beam.CFrame = CFrame.new(tool.Barrel.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
game:GetService("Debris"):AddItem(beam, 0.1)

2 comments
This worked! Was very helpful. Just slightly curious on how I can get the number range into "0.1" increments (giving more freedom to spread, rather than just shoot at 3 different angles(I set it to 3, because 15 made the lasers spread so much, lol))
Edited