Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a shotgun using raycasting?

Asked by 6 years ago

Hi. I've asked this before but still no help. I'm getting closer but I am not familiar with CFrames enough to know what to do next. I'm trying to get all 8 bullets/pellets to have a spread that is consistent no matter where you aim your mouse.

These are the lines of the code I've been using but I don't know what to do and would very much like some help on this if anyone has any suggestions

local ray = Ray.new(tool.Barrel.CFrame.p, (mouse.Hit.p - tool.Barrel.CFrame.p).unit * 300)
local part, position, normal = workspace:FindPartOnRay(ray, player.Character, false, true)  
    for i =0, 7 do
        local beam = makeBeam()
        beam.Parent = pellets
        local distance = 20
        beam.Size = Vector3.new(0.1, 0.1, distance)
        beam.CFrame = CFrame.new(tool.Barrel.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
    end
0
the makebeam function just makes a standard beam and then afterwards the beam is put into a model named "pellets" so I can delete all of the beams at once sonicfan0405 18 — 6y

Answer this question