Roblox Raycast shotgun spread is very horizontal or very vertical

Hello, we are making a shotgun with a random offset for each raycast, not depending on which direction you look, it becomes extremely horizontal, sometimes extremely vertical, unless you move your camera inbetween these directions

Code:

tool.Activated:Connect(function()
		if ready == true and tool:GetAttribute("fullAuto")==false and game.Players.LocalPlayer:GetAttribute("characterLoaded") then
			if canfire == true and Ammo>0  and Reloading==false then
				Ammo-=1
				AmmoWrapper.AmmoLabels.Text=tostring(Ammo).."/"..tostring(tool:GetAttribute("maxAmmo"))
				canfire = false
				
				if tool:GetAttribute("shotgun") then
					count=tool:GetAttribute("pellets")
				else
					count=1
				end
				while count~=0 do
					local camera =workspace.CurrentCamera
					local cameraCF = camera.CFrame
					local Offset = Vector3.new(
						math.random(-Spread*100,Spread*100)/10,
						math.random(-Spread*100,Spread*100),
						math.random(-Spread*100,Spread*100)
					)/300
					fireRemote:FireServer(cameraCF.Position,((cameraCF.LookVector * Offset)+cameraCF.LookVector)*lenght,dmg,tool)
					count-=1
				end
				wait(tool:GetAttribute("cooldown"))
				canfire = true
			end
		else


Looking the opposite way:

Looking inbewteen these directions:

Use Random.new() and create a vector2 which each of them using Random:NextNumber.

then create a cframe thats the muzzle’s cframe (or camera in your case) mutliplied by a cframe rotation containing the spreadvector.

finally multiply the cframe’s lookvector by the muzzle velocity and use that as the velocity parameter in your cast:Fire method.

here’s what i used for my gun system:

local randomX = Random.new()

			local speadVector = Vector2.new(
				math.rad(randomX:NextNumber(-g.Stats.SpreadAngle.Y, g.Stats.SpreadAngle.Y)),
				math.rad(randomX:NextNumber(-g.Stats.SpreadAngle.X, g.Stats.SpreadAngle.X))
			)

			local spreadCframe =  cf.Muzzle * CFrame.Angles(speadVector.X, speadVector.Y, 0)
			local vector = (spreadCframe.LookVector * g.Stats.MuzzleVelocity)
			g._caster:Fire(cf.Muzzle.Position, cf.Muzzle.LookVector, vector, g._behavior)