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 =, (target - laserpos).Unit*250)

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

Thanks all!

For loop, and offset the target with a spread.

for i = 1, 3 do


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