Here is what I wrote:

tool.Equipped:connect(function(mouse)

mouse.Button1Down:connect(function()
	on = true
	if on == true then
		repeat
			
		on = false
		isFiring = true
		local offset = {0.2,0.5,0,7}
        local numnum = offset[math.random(1, #offset)]

		local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p + numnum - tool.Handle.CFrame.p).unit * 100)
		local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
		local beam = Instance.new("Part", workspace)
		beam.BrickColor = player.TeamColor
		beam.FormFactor = "Custom"
		beam.Material = "Neon"
		beam.Transparency = 0.25
		beam.Anchored = true
		beam.CanCollide = false
        tool.Handle.FireSound:Play()
		local distance = (tool.Hole.CFrame.p - position).magnitude
		beam.Size = Vector3.new(0.15, 0.15, distance)
		beam.CFrame = CFrame.new(tool.Hole.CFrame.p, position) * CFrame.new(0,0, -distance / 2)
		
		game:GetService("Debris"):AddItem(beam, 0.1)
		if part then
			local humanoid = part.Parent:FindFirstChild("Humanoid")
 
			if not humanoid then
				humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
			end
 
			if humanoid then
				humanoid:TakeDamage(5)
			
			end
		end
		wait(0.17)
		on = true
		until isFiring == false
	end	
end)
tool.Deactivated:connect(notshoot)
end)		

tool.Unequipped:connect(function(mouse)
	on = false
	isFiring = false
end)

Problem: How do I make the gun fire without perfect accuracy?