local ray = Ray.new(tool.Shooter.CFrame.p, (mouse.Hit.p - tool.Shooter.CFrame.p).unit*300)
I'm stumped on what to change to make this bullet spread.
local ray = Ray.new(tool.Shooter.CFrame.p, (mouse.Hit.p - tool.Shooter.CFrame.p).unit*300)
I'm stumped on what to change to make this bullet spread.
The Ray.new function has a syntax of;
Ray.new( Vector3 origin, Vector3 end)
So what you need to do is offset the look argument by a wanted minimum and maximum CFrame, using math.random.
math.randomseed(tick()) --to make it completely random
--Define offsets for each axis
local xMin,xMax = 0,10
local yMin,yMax = 0,10
local zMin,zMax = 0,10
--Define origin
local origin = tool.Shooter.CFrame
--Define look as mouse.Hit multiplied by randomized offsets
local look = mouse.Hit * CFrame.new(
math.random(xMin,xMax),
math.random(yMin,yMax),
math.random(zMin,zMax)
)
--Create the ray
local ray = Ray.new(origin.p, (look.p - origin.p).unit*300)
This discussion is preserved as it was. New answers, comments, and votes are closed.