How can I turn this code to work as a shotgun code

Hi, I wanna make a shotgun. But I don’t know how so, I have an existing code that I’d like to turn it in a shotgun, here’s the code:

**BeamEvent.OnServerEvent:Connect(function(Player, laserpos, target)
	local ray = Ray.new(laserpos, (target - laserpos).Unit*250)

			local hit, position = game.Workspace:FindPartOnRay(ray, nil)
		pcall(function()
		local HumanoidToDamage = hit.Parent:FindFirstChild("Humanoid")
		if HumanoidToDamage and HumanoidToDamage ~= Player.Character.Humanoid then
			HumanoidToDamage:TakeDamage(20)
			print(HumanoidToDamage.Parent.Name .. " just got hit by beam. ")
		end
		local Beam = Instance.new("Part", game.Workspace)
		Beam.Name = "Beam"
		local dist = (target - laserpos).magnitude
		Beam.Size = Vector3.new(0.3,0.3, dist)
		Beam.CFrame = CFrame.new(laserpos, position) * CFrame.new(0,0,-dist/2)
		Beam.Anchored = true
		Beam.CanCollide = false
		Beam.BrickColor = BrickColor.new("Really red")
		Beam.Material = Enum.Material.Neon
		debris:AddItem(Beam, 0.01)
	end)
end)

Thanks all!

For loop, and offset the target with a spread.

for i = 1, 3 do

 end

but I don’t know how to do spread

Add some random noise to the direction parameter of the Ray. Nothing too sharp but just something that shows it’s spreading.

Also, couldn’t you have just looked it up using the search function? It’s not particularly hard to search on the forums.

What do you mean by random, can you please give an example?

I did give an example. I gave you a literal thread that has the exact same question you asked. Please consider checking out the thread

I’m really sorry I didn’t notice, sorry again